From: "Paul Moore" <lists@morpheus.demon.co.uk> > Oren Tirosh <oren-py-d@hishome.net> writes: > > > I agree. I don't see anything wrong with > > > > f=open('spam', 'r') > > with autoclose(f): > > ... > > I *like* this way of doing autoclose files. Much better than the way > I've been thinking > > f = autocloser("spam") > with f: > ... > > > and I think that > > > > with autolock(obj): > > ... > > > > looks better than any other alternative proposed so far. > > On the other hand, I quite like > > with lock: > ... > > (where lock is defined appropriately). > > I don't know. Does the fact that the same statement is best used in > two subtly different ways (permanent object vs throwaway helper > object) count as a disadvantage of the statement (in terms of > teachability, if nothing else...)? it depends on how you look at things, either your main object support the 'with' protocol or not: with with_proto_supporting_object: ... or it needs an adapter: with with_proto_adpater(obj): ... Anyway write the PEP and leave this behind you <wink>.
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