Guido van Rossum wrote:

> - Greg Ewing (I believe) wants 'do' instead of 'with' for the
>   keyword.  I think I like 'with' better, especially combining it with
>   Benji's proposal.  IMO this reads better with 'with' than with 'do':
> 
>     with open("/etc/passwd") as f:
>         for line in f:
>             ...

I don't think I like the idea of giving the file object
itself __enter__ and __exit__ methods, because it doesn't
ensure that the opening and closing are done as a pair.
It would permit the following kind of mistake:

   f = open("somefile")
   with f:
     do_something()
   with f:
     do_something_else()

which our proposed construct, if it is any good, should
be able to prevent.

Also I don't at all agree that "with open(...)" reads
better; on the contrary, it seems ungrammatical.
Especially when compared with the very beautiful
"do opening(...)", which I would be disappointed
to give up.

I still also have reservations about "with" on the
grounds that we're making it mean something very
different to what it means in most other languages
that have a "with".

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | A citizen of NewZealandCorp, a       |
Christchurch, New Zealand          | wholly-owned subsidiary of USA Inc.  |
[EMAIL PROTECTED]          +--------------------------------------+
_______________________________________________
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

Reply via email to