I have a tree. I have several tasks that involving scanning the whole tree.
I would like to write a function, say scanTree ()
for instance that will scan a tree in a particular order, then returns an iterable object.
The idea is:
def task1 (self):
x = self.scanTree ()
for y in x:
do_something1(y)
def task2 (self):
x = self.scanTree ()
for y in x:
do_something2(y)
But I don't know what kind of object I can return in function scanTree
.
Could you give me some hints?
Thank you very much,