0

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.

asked Oct 27, 2010 at 8:37
1
  • How sad that the Python tutorials weren't working. Which tutorial have you been using? How long has it been down? Commented Oct 27, 2010 at 10:23

2 Answers 2

3

It signifies a decorator

answered Oct 27, 2010 at 8:40
Sign up to request clarification or add additional context in comments.

Comments

0

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))

answered Oct 27, 2010 at 8:46

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.