[Tutor] decorators (the "at" sign)?

Alex Hall mehgcap at gmail.com
Tue Oct 26 04:46:52 CEST 2010

Hi all,
Now that I am able to run the source code of an open source
application I hope to one day help develop, I am trying to understand
how it works. One thing I keep seeing is an at sign followed by a
word, usually (maybe always) immediately preceeding a function
definition. For example, and I know this exact code will not make much
sense, but it gives the idea:
class Bing(Messages, Updating, Dismissable):

 def get_url(self, index=None):
  return self.storage[index]['Url']

What is the "@set_index" for? Specifically, what is the at sign doing?
Google was only able to provide me with a very vague idea of what is
going on, though it seems to crop up a lot in classmethod and
staticmethod calls (not sure about those either). I read PEP 318, but
it was not much help since I am coming at this having no idea what I
am looking at. The PEP did explain why I have never run into this
before, though - it is apparently specific to Python. I see this sort
of thing all over this source code so it seems like a good idea to get
exactly what it is for. TIA!

Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap

More information about the Tutor mailing list