Maybe, just maybe @decorator syntax is ok after all

AdSR artur_spruce at yahoo.com
Mon Aug 9 10:07:54 EDT 2004


artur_spruce at yahoo.com (AdSR) wrote in message news:<b840abf4.0408080422.44fcf41c at posting.google.com>...
> <snip>
> @dec1
> @dec2
> def foo():
>     pass
> 
> <snip> 
> 
> and after the second:
> 
> def foo():
>     pass
> 
> foo = dec2(foo)
> 
> foo = dec1(foo)

The latter is equivalent to:

def foo():
    pass
foo = dec1(dec2(foo))

But I've just noticed that the spec says:

"""
@f1
@f2
def func(): pass

is equivalent to:

def func(): pass
func = f2(f1(func))
"""

So the order is reverse, which breaks my previous interpretation. Oh, well...

AdSR



More information about the Python-list mailing list