On 4/21/05, Guido van Rossum <[EMAIL PROTECTED]> 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)
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com