Phillip J. Eby wrote:

> Why?  If "with" is a "scope statement", then it doesn't make any sense 
> to use it with something you intend to reuse later.  The statement 
> itself is an assertion that you intend to "release" the resource at the 
> end of the block, for whatever "release" means to that object.  
> Releasing a file is obviously closing it, while releasing a lock is 
> obviously unlocking it.

I've stopped arguing against giving with-protocol
methods to files, etc., since it was pointed out that
you'll get an exception if you try to re-use one.

I still think it's conceptually cleaner if the object
you use to access the resource is created by the
__enter__ method rather than being something pre-
existing, but I'm willing to concede that PBP here.

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