Thomas Girod wrote: > Hello there. > > I recently started looking at turbogears and I found code such as : > > class Root(controllers.Root): > @turbogears.expose(html="blog.templates.accueil") > def index(self,**kw): > return dict() > > > What is this "@" ? I looked around but couldn't find any references to > this syntax.
It is called a decorator syntax, and is basically syntactic sugar for the following: class Foo(object): def bar(self): pass bar = decorate(bar) is class Foo(object): @decorate def bar(self): pass You can also have parameterized decorators, as the ones in TG: class Foo(object): def bar(self): pass bar = decorate_with_args("some argument")(bar) is class Foo(object): @decorate_with_args("some argument") def bar(self): pass I suggest you read this to get on speed with decorators: http://www.phyast.pitt.edu/~micheles/python/documentation.html Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list