What does the at sign do?
"Martin v. Löwis"
martin at v.loewis.de
Tue Dec 16 17:09:30 EST 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