Skip to content Skip to sidebar Skip to footer

"@" Decorator (in Python)

Possible Duplicate: Understanding Python decorators What function does the 'class decorator'/'method decorator' (@) serve? In other words, what is the difference between this an

Solution 1:

@decoratordeffunction(args):
    #body

is just syntactic sugar for:

def function(args):
    #bodyfunction = decorator(function)

That's really it.

As you see, the decorator gets called, so it's by no means a comment.

Post a Comment for ""@" Decorator (in Python)"