John Fouhy wrote:
> def walkTree(tree):
>     # stack to hold nodes as we walk through
>     stack = []
>     stack.append(tree)
> 
>     while stack:
>         value, children = stack.pop()
>         for child in reversed(children):  # reverse children to get
> the right order.
>             stack.append(child)

FWIW this could be written as
   stack.extend(reversed(children))

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to