for: else: - any practical uses for the else clause?

metaperl metaperl at gmail.com
Fri Sep 29 03:45:55 EDT 2006


Actually right after posting this I came up with a great usage. I use
meld3 for my Python based dynamic HTML generation. Whenever I plan to
loop over a tree section I use a for loop, but if there is no data to
iterate over, then I simply remove that section from the tree or
populate it with a "no data" message.




More information about the Python-list mailing list