I have the following code:
>>> def test(a,b,c,d):
... print([x in [a,b,c,d] for x in [1,]])
... print([x in list(locals().values()) for x in [1,]])
>>> test(1, 2, 3, 4)
[True]
[True]
>>> test(2, 2, 3, 4)
[False]
[True]
This implementation might seem a bit weird, but the example stems from a bigger project where there are many function arguments.
For the first call of the function, everything behaves as expected with the same result for both statements. For the second call, however, the behaviour seems very strange to me. Can anybody explain what's going on here?
Thanks!