Tree() length
I made Tree().__len__() to use for finding the number of leafs that exist on a tree.
This commit is contained in:
parent
99ea5fd3ed
commit
019cded563
|
@ -6,6 +6,12 @@ class Tree(dict):
|
|||
def __init__(self):
|
||||
dict.__init__(self)
|
||||
|
||||
def __len__(self):
|
||||
count = 0;
|
||||
for path in self.walk():
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def __disp__(self, level):
|
||||
return "%s (%s)", (child, self[child].value)
|
||||
|
||||
|
|
Loading…
Reference in New Issue