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 | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.blogspot.com _______________________________________________ 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