Question: my table looks like this (all columns are nvarchar):

```
| col1 | col2 | col3 |
----------------------
|  ... | FFF8 | ...  |
|  ... |  -1  | ...  |
|  ... | FFF6 | ...  |
|  ... |  -9  | ...  |

```

If the value in the second column is not "-1" or "-9" i want to convert from hex to binary i. Any suggestions?

Answer: 
My preferred way of iterating over several widgets in pyqt is storing them as objects in lists.

```
myButtons = [self.ui.phase_scan_button, self.ui.etalon_scan_button,
             self.ui.mirror_scan_button, self.ui.gain_scan_button]
for button in myButtons:
    button.clicked.connect(lambda _, b=button: self.scan_callback(scan=b))

```

If you need the strings "phase", "etalon", "mirror" and "gain" separately, you can either store them in another list, or create a dictionary like

```
myButtons_dict = {"phase": self.ui.phase_scan_button,
                 "etalon": self.ui.etalon_scan_button,
                 "mirror": self.ui.mirror_scan_button,
                 "gain": self.ui.gain_scan_button}

for button in myButtons_dict:
    myButtons_dict[button].clicked.connect(lambda: _, b=button self.scan_callback(scan=b))

```

Note, how I use the lambda expression with solid variables that are then passed into the function `self.scan_callback`. This way, the value of `button` is stored for good.
Your lambdas do **not** store the *value* of `button` when it is defined. The code describing the lambda function is parsed and compiled **but not executed until you actually call the lambda**.
Whenever any of the buttons is clicked, the *current value of variable* `button` is used. At the end of the loop, `button` contains `"gain"` and this causes the behaviour you see.

Try this:

```
funcs = []
for button in ['phase', 'etalon', 'mirror', 'gain']:
    funcs.append( lambda : print(button))

for fn in funcs:
  fn()

```

The output is:

```
gain
gain
gain
gain

```

Extending the example, as a proof that the lambdas don't store the value of `button` note that if `button` stops existing, you'll have an error:

```
del button
for fn in funcs:
  fn()

```

which has output

```
funcs.append( lambda : print(button))
NameError: name 'button' is not defined

```