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
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