Skip to content

Commit 063a40f

Browse files
committed
[section] Order magic methods
1 parent d3430bb commit 063a40f

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

odml/section.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,22 @@ def __init__(self, name, type=None, parent=None,
5555
self.parent = parent
5656

5757
def __repr__(self):
58-
return "<Section %s[%s] (%d)>" % (self._name, self.type,
59-
len(self._sections))
58+
return "<Section %s[%s] (%d)>" % (self._name, self.type, len(self._sections))
59+
60+
def __iter__(self):
61+
"""
62+
Iterate over each section and property contained in this section
63+
"""
64+
for section in self._sections:
65+
yield section
66+
for prop in self._props:
67+
yield prop
68+
69+
def __len__(self):
70+
"""
71+
Number of children (sections AND properties)
72+
"""
73+
return len(self._sections) + len(self._props)
6074

6175
@property
6276
def id(self):
@@ -350,21 +364,6 @@ def remove(self, obj):
350364
else:
351365
raise ValueError("Can only remove sections and properties")
352366

353-
def __iter__(self):
354-
"""
355-
Iterate over each section and property contained in this section
356-
"""
357-
for section in self._sections:
358-
yield section
359-
for prop in self._props:
360-
yield prop
361-
362-
def __len__(self):
363-
"""
364-
Number of children (sections AND properties)
365-
"""
366-
return len(self._sections) + len(self._props)
367-
368367
def clone(self, children=True):
369368
"""
370369
Clone this object recursively allowing to copy it independently

0 commit comments

Comments
 (0)