Language Semantics: @ symbol??

Jay Parlar jparlar at cogeco.ca
Sun Jan 29 21:38:17 EST 2006


Enigma Curry wrote:
>
>
> Sorry, for the noob question, but I haven't been able to find
> documentation on this matter.
>
> I've been looking for documentation that describes what the @function()
> syntax is all about.
>
> I've seen this on a few pages, for instance:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/307871
>
> and also in TurboGears:
>
> http://www.turbogears.com/docs/wiki20/page5.html
>
> The general format appears to be:
>
> @somefunction()
> def a_newfunction():
>     ....
>
> What does it mean and what does it do?
>
> Thanks!

It's called a decorator, new in Python 2.4:

http://python.org/doc/2.4.2/whatsnew/node6.html

Not sure where it lives in the official documentation right now 
though... Maybe someone else can provide that.

Jay P.




More information about the Python-list mailing list