Gooner
Gooner

Reputation: 1398

Python Syntax doubt

Hey, I have been using the Pymt library and they have this convention to referring their widgets:

from pymt import *

# create a slider from 0.-1.
sl = MTXYSlider()

@sl.event
def on_value_change(x, y):
    print 'Slider value change', x, y

runTouchApp(sl)

what's with the "@"? What does it signify in Python?Thanks.

Upvotes: 0

Views: 78

Answers (2)

mossplix
mossplix

Reputation: 3865

basically it is a function that takes another function as an argument . if is a way python implements a Decorator Pattern.

the equivalent code would be


sl.event(on_value_change(x, y))




Upvotes: 0

John La Rooy
John La Rooy

Reputation: 304167

It signifies a decorator

Upvotes: 3

Related Questions