What does the at sign do?

"Martin v. Löwis" martin at v.loewis.de
Tue Dec 16 23:09:30 CET 2008


> I'm reading a lot of python code lately, django code to be exact, and
> I keep bumping into expressions that look like this
> @register.filter
> 
> I see nothing importing @register, so I assume it's not just a
> function name. 

That can't be. register must be a bound name - not necessarily an
imported function; it could also be something being set through
assignment (register = Registry()).

> Yet I cannot figure where this @ sign came from.

That's a function decorator; see PEP 318.

Regards,
Martin



More information about the Python-list mailing list