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/2005-July/054753.html below:

[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343 [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343Nick Coghlan ncoghlan at gmail.com
Fri Jul 8 16:21:35 CEST 2005
Phillip J. Eby wrote:
> I suggest changing this to something like this:
> 
>     class tag(object):
>         def __init__(self,name):
>             self.name = name
>         def __enter__(self):
>             print "<%s>" % name
>         def __exit__(self):
>             print "</%s>" % name
> 
>     with tag('html'):
>         # ... etc.
> 
> So that it's obvious where the implementation is coming from.  
> Otherwise, it looks altogether too magical.

Done - included in the latest version on SF. [1]

> Also, the posted draft doesn't explain what happens to the __enter__ 
> return value, either in a literal sense or in the sense of where it fits 
> in the overall concept of context management.

I've tried to clarify this by showing usage of the closing() context manager.

Cheers,
Nick.

[1] http://www.python.org/sf/1234057

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
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