Tree() length

I made Tree().__len__() to use for finding the number of leafs that
exist on a tree.
This commit is contained in:
Bryan Schumaker 2010-11-09 20:07:35 -05:00
parent 99ea5fd3ed
commit 019cded563
1 changed files with 6 additions and 0 deletions

View File

@ -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)