0

Possible Duplicate:
What does @ mean in Python?

Here is the code I don't understand:

def coroutine(func):
   def start(*args,**kwargs):
      cr = func(*args, **kwargs)
       #cr.next()
       next(cr)
       return cr
   return start

@coroutine #<<<----- HERE
def detectChange(value):
   old_value = value
    while True:
       new_value = (yield)
       if new_value != old_value:
          print ("Ouch!")
          old_value = new_value

What does the @coroutine means syntax wise?

Community
  • 1
  • 1
ALucero
  • 21
  • 1
  • 7

3 Answers3

1

It's a function decorator.

Danica
  • 28,423
  • 6
  • 90
  • 122
0

It's a decorator: http://www.artima.com/weblogs/viewpost.jsp?thread=240808

Tim McLean
  • 1,576
  • 3
  • 14
  • 20
0

Decorators wrap functions: http://wiki.python.org/moin/PythonDecorators

Marcin
  • 48,559
  • 18
  • 128
  • 201