Bernhard Herzog wrote: > "M.-A. Lemburg" <mal@lemburg.com> writes: > > >>try: >> with mylock: >> ... >>finally: >> ... other cleanup code ... >> >>The new syntax saves you one line and obscures the code >>rather than clarifying what is happening (who knows what >>mylock does in its __enter__/__exit__ method ?). > > If you come across an unfamiliar function or type you look it up in the > documentation or the source. I don't see the problem here. RTFM fits in with all obfuscation. I don't think that it does with Python's "explicit is better than implicit". >>The original argument for this was not to save you typing, >>it was built on the rather unlikely case where the process >>receives a signal or MemoryError causing an exception while >>executing the byte codes after calling .acquire() and before >>entering the try-block. >> >>However, that's not hard to deal with either because >>all you need to do is place the .acquire() call inside >>the try-block and then adding a check whether you have to >>release the lock in the finally-clause. > > That just moves the race condition to a different place. If the acquire > call is inside the try block the place of the race condition is between > the acquire call and setting a flag or in the finally clause between > checking a flag and actually releasing the lock. Not if the lock object is protected by the global interpreter lock which usually is the case if the lock object is implemented C. Anyway, I don't want to argue here. Just give my vote. Thanks, -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Feb 10 2003) >>> Python/Zope Products & Consulting ... http://www.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ Python UK 2003, Oxford: 50 days left EuroPython 2003, Charleroi, Belgium: 134 days left
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