[prev in list] [next in list] [prev in thread] [next in thread]
List: python-ideas
Subject: Re: [Python-ideas] A couple of with statement ideas
From: Nick Coghlan <ncoghlan () gmail ! com>
Date: 2011-02-27 23:58:51
Message-ID: AANLkTimpqGFCAK=XMrCPn52Ei5vuDe07BH-yD4xdcVG- () mail ! gmail ! com
[Download RAW message or body]
On Mon, Feb 28, 2011 at 8:36 AM, Tal Einat <taleinat@gmail.com> wrote:
> Unless I misunderstood, this (__with__ or whatever it ends up being called)
> would be an alternate method of implementing a context manager, so why not
> just call these "context managers" just like objects with __enter__ and
> __exit__ are?
Because that's precisely the terminology confusion that got
__context__ dropped from PEP 343 in the first place. To make the
standard comparison, even iterators and iterables are not the same
thing, even though the former are a subset of the latter. In this
case, where objects would be expected to implement __with__ or
__enter__/__exit__, but never both, the distinction should be kept
even more clear.
Basically, __with__ should be a context manager factory function,
while context managers themselves are still required to implement
__enter__/__exit__.
Personally, my preference still goes to "objects with an implicit
context manager".
That said, until someone steps forward to write the PEP and make the
case for bringing this idea back *at all*, the detailed terminology
discussion is fairly moot.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic