Am Sonntag 21 Mai 2006 20:31 schrieb Terry Reedy: > Isn't this the same as > > for node in tree: > if node.haschildren(): > <do something with node> > > so that all you would save is ':\n' and the extra indents?
Saving an extra indent and the ':\n' makes it quite a bit easier for me to read and understand in the long run. I find: for x in range(10): if not x % 2: print "Another even number:", print x ... print "Finished processing the even number" a lot harder to read and understand than: for x in range(10): if x % 2: continue print "Another even number:", print x ... print "Finished processing the even number" because with the latter it's much more obvious for me how the flow of control in the indented block is structured (and to what part of the loop the condition applies, namely to the whole loop body). That's why I'd prefer the "combination" of the two as: for x in range(10) if not x % 2: print "Another even number:", print x ... print "Finished processing the even number" because the logic is immediately obvious (at least if you find the logic to be obvious when reading list comprehensions, simply because the format is similar), and there's no extra indentation (as in your example), which makes the block, as I said, a lot easier to parse for my brain. But, probably, that's personal preference. --- Heiko. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com