A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-April/063863.html below:

[Python-Dev] Why are contexts also managers? (was r45544

[Python-Dev] Why are contexts also managers? (was r45544 - peps/trunk/pep-0343.txt) [Python-Dev] Why are contexts also managers? (was r45544 - peps/trunk/pep-0343.txt)Phillip J. Eby pje at telecommunity.com
Tue Apr 18 21:37:37 CEST 2006
At 04:18 PM 4/18/2006 -0400, A.M. Kuchling wrote:
>On Tue, Apr 18, 2006 at 08:55:18PM +0200, phillip.eby wrote:
> > Modified:
> >    peps/trunk/pep-0343.txt
> >
> > +    "context manager" then encompasses all objects with a __context__()
> > +    method that returns a context object.  (This means that all contexts
> > +    are context managers, but not all context managers are contexts).
>
>This change reminds of another question I had about the parenthetical
>statement: all contexts are context managers (= 'has a __context__'
>method).  Why?  The context object isn't necessarily available to the
>Python programmer, so they can't write:
>
>with context_mgr as context:
>      with context:  # uses the same context
>          ...
>
>Why do contexts need to have a __context__() method?

I was going to say, "so they can be context managers", but I suppose you 
have a point.  There is no need for a context to have a __context__ method, 
unless it is also a context manager.  Ugh.


More information about the Python-Dev mailing list

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