I have the following:
>>> {c: (lambda: c) for c in ["A","B"]}["A"]()
'B'
when I expect the result to be 'A'
.
Note that
>>> {c: c for c in ["A","B"]}["A"]
'A'
Are lambdas not allowed in dictionary comprehensions or have I screwed up the syntax?