A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-April/053130.html below:

[Python-Dev] PEP 340 - possible new name for block-statement

[Python-Dev] PEP 340 - possible new name for block-statementNick Coghlan ncoghlan at gmail.com
Fri Apr 29 10:58:03 CEST 2005
Guido van Rossum wrote:
> How about, instead of trying to emphasize how different a
> block-statement is from a for-loop, we emphasize their similarity?

If you want to emphasise the similarity, the following syntax and explanation is 
something that occurred to me during lunch today:

Python offers two variants on the basic iterative loop.

   "for NAME from EXPR:" enforces finalisation of the iterator. At loop 
completion, a well-behaved iterator is always completely exhausted. This form 
supports block management operations, that ensure timely release of resources 
such as locks or file handles.
   If the values being iterated over are not required, then the statement may be 
simplified to "for EXPR:".

   "for NAME in EXPR:" skips the finalisation step. At loop completion, a 
well-behaved iterator may still contain additional values. This form allows an 
iterator to be consumed in stages.


Regardless of whether you like the above or not, I think the PEP's proposed use 
of 'as' is incorrect - it looks like the variable should be referring to the 
expression being iterated over, rather than the values returned from the iterator.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4