0

I was trying out Pyglet via this tutorial when I noticed this portion of the code, which is not documented on the page.. I have not been able to find anything on it by searching the web either.

What exactly does it do? Can it be used with other objects?

    @window.event
ever99
  • 65
  • 1
  • 6
  • 2
    It’s a [decorator](https://wiki.python.org/moin/PythonDecorators). – Ry- Jan 16 '14 at 02:51
  • 1
    You may want to take a look at [this answer](http://stackoverflow.com/questions/739654/how-can-i-make-a-chain-of-function-decorators-in-python/1594484#1594484) – Sean Vieira Jan 16 '14 at 02:57
  • Thank you both for clearing this up for me (: – ever99 Jan 16 '14 at 02:58

1 Answers1

0

It "decorates" the following function/method/class

@window.event
def f(foo):
    return bar

Is equivalent to

def f(foo):
    return bar
f = window.event(f)
John La Rooy
  • 295,403
  • 53
  • 369
  • 502