[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: for-else

egbert

3/9/2008 3:38:00 PM

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
========================================================================