for-else

egbert egbert.bouwman at hccnet.nl
Sun Mar 9 11:38:10 EDT 2008


On Sat, Mar 08, 2008 at 04:15:31PM -0500, Terry Reedy wrote:
> 
> I am sorry if you cannot appreciate such elegance 
> and can only spit on it as 'orwellian'.
> 
I admire the elegance of your examples and your explanation.
I will keep a copy of it in my Beazley,
for I am afraid I have to read it again.
As for orwellian, I must admit 
that I was quite happy when I thought of using that word, 
but that it was not my luckiest thought.

But I have to persist in my malice.

In the following snippet it is not at all clear
to the naive programmer (me) that the else refers to an 
iterator_is_exhausted condition,
whatever logical explanation you may offer.

.  for each_item in item_list:
.    do_something()
.  else:
.    do_else()

My temporary solution will be to accompany this else
with an appropriate comment: # exhausted

e
-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991
========================================================================



More information about the Python-list mailing list