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/052901.html below:

[Python-Dev] Re: anonymous blocks

[Python-Dev] Re: anonymous blocks [Python-Dev] Re: anonymous blocksTerry Reedy tjreedy at udel.edu
Mon Apr 25 16:14:07 CEST 2005
"Fredrik Lundh" <fredrik at pythonware.com> wrote in message 
news:d4i6hg$q88$1 at sea.gmane.org...
> Guido van Rossum wrote:
>
>> At the same time, having to use it as follows:
>>
>>     for f in with_file(filename):
> <         for line in f:
>>             print process(line)
>>
>> is really ugly, so we need new syntax, which also helps with keeping
>> 'for' semantically backwards compatible. So let's use 'with', and then
>> the using code becomes again this:
>>
>>     with f = with_file(filename):
>>         for line in f:
>>            print process(line)
>
> or
>
>    with with_file(filename) as f:

with <target> as <value>:

would parallel the for-statement header and read smoother to me.

for <target> as <value>:

would not need new keyword, but would require close reading to distinguish 
'as' from 'in'.

Terry J. Reedy



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