> @acquire(myLock):
>     code
>     code
>     code

It would certainly solve the problem of which keyword to use! :-) And
I think the syntax isn't even ambiguous -- the trailing colon
distinguishes this from the function decorator syntax. I guess it
would morph '@xxx' into "user-defined-keyword".

How would acquire be defined? I guess it could be this, returning a
function that takes a callable as an argument just like other
decorators:

def acquire(aLock):
    def acquirer(block):
        aLock.acquire()
        try:
            block()
        finally:
            aLock.release()
    return acquirer

and the substitution of

@EXPR:
    CODE

would become something like

def __block():
    CODE
EXPR(__block)

I'm not yet sure whether to love or hate it. :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to