Why does Python return [15] for [0xfor x in (1, 2, 3)]? [duplicate]
TL;DR Python reads the expression as [0xf or (x in (1, 2, 3))], because: The Python tokenizer. Operator precedence. It never raises NameError thanks to short-circuit evaluation – if the expression left to the or operator is a truthy value, Python will never try to evaluate the right side of it. Parsing hexadecimal numbers First, … Read more