Skip to content Skip to sidebar Skip to footer

Lambda Function And Variable Scope

Currently, my code is like this: for control in self.controls(): self.connect(control, SIGNAL('clicked()'), lambda: self.button(control.objectName())) When I run my code, my lam

Solution 1:

SPLAT.

for control in self.controls():
  self.connect(control, SIGNAL('clicked()'), lambda control=control:
    self.button(control.objectName()))

Post a Comment for "Lambda Function And Variable Scope"