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

```
As noted here : [Connecting slots and signals in PyQt4 in a loop](https://stackoverflow.com/questions/4578861/connecting-slots-and-signals-in-pyqt4-in-a-loop)
Using `functools.partial` is a nice workaround for this problem.

Have been struggling with same problem as OP for a day.