Python loop | "do-while" over a tree
Posted
by johannix
on Stack Overflow
See other posts from Stack Overflow
or by johannix
Published on 2009-10-02T19:57:51Z
Indexed on
2010/04/29
13:47 UTC
Read the original article
Hit count: 259
python
Is there a more Pythonic way to put this loop together?:
while True:
children = tree.getChildren()
if not children:
break
tree = children[0]
UPDATE: I think this syntax is probably what I'm going to go with:
while tree.getChildren():
tree = tree.getChildren()[0]
© Stack Overflow or respective owner