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/054778.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 343Nick Coghlan ncoghlan at gmail.com
Sat Jul 9 03:03:09 CEST 2005
Terry Reedy wrote:
> Would this also work as a decorated generator?
> (If I have understood correctly, something like..)
> 
> @contextmanager
> def tag(name)
>        print "<%s>" % name
>        yield None
>        print "</%s>" % name
> 
> If so, I suggest putting in both versions to make the correspondence clear.

Hmm, good idea. I think I'll do that with 'closing' as well, since the 
resource management section could use a better example.

> To whoever invented this example: thanks.  It rang a bell with me so I 
> could see this as a generally usefully feature rather than a specialized 
> (though for some, important) 'close resource' feature.
> 
> The particularly neat thing is that it converts the indent-dedent method of 
> showing structure to the alternative matched-fences method.   This is 
> certainly not limited to HTML generation.

By using closing(), decimal.getcontext(), and tag() as examples, it should be 
possible to show the versatility of the construct without making the 
documentation too confusing.

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