"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 _______________________________________________ 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