On 4/21/05, Guido van Rossum <gvanrossum at gmail.com> wrote: > for dummy in synchronized(the_lock): > BODY > > or perhaps even (making "for VAR" optional in the for-loop syntax) > with > > in synchronized(the_lock): > BODY > > Then synchronized() could be written cleanly as follows: > > def synchronized(lock): > lock.acquire() > try: > yield None > finally: > lock.release() How is this different from: def synchronized(lock): def synch_fn(block): lock.acquire() try: block() finally: lock.release() return synch_fn @synchronized def foo(): BLOCK True, it's non-obvious that foo is being immediately executed, but regardless I like the way synchronized is defined, and doesn't use yield (which in my opinion is a non-obvious solution)
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