On 4/21/05, Guido van Rossum
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)