[Python-Dev] PEP 340 -- loose ends

Eric Nieuwland eric.nieuwland at xs4all.nl
Thu May 5 16:36:03 CEST 2005


Reinhold Birkenfeld wrote:
> Shane Hathaway wrote:
>> PEP 340 seems to punish people for avoiding the parentheses:
>>
>>     transaction = begin_transaction()
>>
>>     transaction:
>>         db.execute('insert 3 into mytable')
>>
>>     transaction:
>>         db.execute('insert 4 into mytable')
>>
>> I expect that only '3' would be inserted in mytable.  The second use 
>> of
>> the transaction iterator will immediately raise StopIteration.
>
> Yes, but wouldn't you think that people would misunderstand it in this 
> way?

This could be solved if the translation of

         block EXPR1 as VAR1:
             BLOCK1
would change from:
         itr = EXPR1  # The iterator
         ret = False  # True if a return statement is active
         ...etc...
to:
         itr = iter(EXPR1)  # The iterator
         ret = False  # True if a return statement is active
         ...etc...

--eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1134 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20050505/bda648c0/attachment.bin


More information about the Python-Dev mailing list