Andreas Waldenburger wrote:
On Sun, 08 Feb 2009 01:28:00 +1100 Steven D'Aprano
<st...@pearwood.info> wrote:
Andreas Waldenburger wrote:
It seems that there is a for...else construct. Replacing the inner
if with pass seems to confirm this. The else clause is still
executed.
Yes, there is a for...else construct.
That's something. In 6+ years of Python programming I've never seen or
heard of this thing. This might be useful, apparently.
One use case is:
for x in list_of_items:
if x.value == desired_value:
desired_name = x.name
break
else:
print "Couldn't find %s" % x.value
[snip]
What's broken here: Python or my brain?
Perhaps we should not answer that question.
I did phrase that rather provocatively, didn't I?
Well thanks. I'll try to learn less noisily in the future. :)
--
http://mail.python.org/mailman/listinfo/python-list