On Sun, 08 May 2005 14:16:40 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote:
>Ron Adam wrote:
>> I agree, re-using or extending 'for' doesn't seem like a good idea to me.
>
>I agree that re-using a straight 'for' loop is out, due to performance and
>compatibility issues with applying finalisation semantics to all such iterative
>loops (there's a reason the PEP redraft doesn't suggest this).
>
>However, it makes sense to me that a "for loop with finalisation" should
>actually *be* a 'for' loop - just with some extra syntax to indicate that the
>iterator is finalised at the end of the loop.
>
>An option other than the one in my PEP draft would be to put 'del' at the end 
>of
>the line instead of before EXPR:
>
>   for [VAR in] EXPR [del]:
>       BLOCK1
>   else:
>       BLOCK2
>
>However, as you say, 'del' isn't great for the purpose, but I was trying to
>avoid introduding yet another keyword. An obvious alternative is to use
>'finally' instead:
>
>   for [finally] [VAR in] EXPR:
>       BLOCK1
>   else:
>       BLOCK2
>
>It still doesn't read all that well, but at least the word more accurately
>reflects the semantics involved.

  If such a construct is to be introduced, the ideal spelling would seem to be:

    for [VAR in] EXPR:
        BLOCK1
    finally:
        BLOCK2

  Jp
_______________________________________________
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

Reply via email to