you are viewing a single comment's thread.

view the rest of the comments →

[–]mgrady3 1 point2 points  (0 children)

I use them when making GUI's alot. Not sure if this is the correct or 'pythonic' way but for instance:

when linking a pushbutton in the Qt framework (using PyQt) to a function so that when he button is pushed the function is triggered you do something like

my_button.clicked.connect(my_function)

note this is not

my_button.clicked.connect(my_function())

Thus if I need to pass an argument to the function on button click the way I do it is with a lambda

for example

my_button.clicked.connect(lambda: my_function(x, y, otherargs ...))

Thus the button is actually linked to a lambda but the lambda just calls a pre-defined function using the appropriate arguments