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