diff options
author | syt <syt@localhost.localdomain> | 2006-11-23 15:37:29 +0100 |
---|---|---|
committer | syt <syt@localhost.localdomain> | 2006-11-23 15:37:29 +0100 |
commit | 1bfddfdb575c57d6383efefdb13a44ccd56b3be1 (patch) | |
tree | 98c4d05d03664d0893bb672207dacc639bbc301f /tree.py | |
parent | c642a7e6d32438bc78947b6f967a6118f3fa0650 (diff) | |
download | logilab-common-1bfddfdb575c57d6383efefdb13a44ccd56b3be1.tar.gz |
make Node iterable
Diffstat (limited to 'tree.py')
-rw-r--r-- | tree.py | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -19,6 +19,7 @@ import sys +from logilab.common import flatten from logilab.common.visitor import VisitedMixIn, FilteredIterator, no_filter ## Exceptions ################################################################# @@ -182,16 +183,14 @@ class Node : else: return [self] + def __iter__(self): + return iter(self.children) + def flatten(self, _list=None): """ return a list with all the nodes descendant from this node """ - if _list is None: - _list = [] - _list.append(self) - for c in self.children: - c.flatten(_list) - return _list + return flatten(self) def lineage(self): """ |