I'm connecting multiple signal/slots using a for loop in PyQt. The code is bellow:
# Connect Scan Callbacks
for button in ['phase', 'etalon', 'mirror', 'gain']:
    getattr(self.ui, '{}_scan_button' .format(button)).clicked.connect(
        lambda: self.scan_callback(button))
What I expect:
- Connect button 
phase_scan_buttonclickedsignalto thescan_callbackslotand send the stringphaseas a parameter to theslot. The same foretalon,mirrorandgain. 
What I'm getting:
- For some reason my functions is always passing the string 
gainas parameter for all the buttons. Not sure if I'm being stupid (likely) or it is a bug. 
For reference, the slot method:
def scan_callback(self, scan):
    print(scan) # Here I always get 'gain'
    if self.scanner.isWorking:
        self.scanner.isWorking = False
        self.scan_thread.terminate()
        self.scan_thread.wait()
    else:
        self.scanner.isWorking = True
        self.scan_thread.start()
        getattr(self.ui, '{}_scan_button' .format(
            scan)).setText('Stop Scan')
        getattr(self, '_signal{}Scan' .format(scan)).emit()