Re:In Python, `[0xfor x in (1, 2, 3)]` returns `[15]`
by klyrs on Tuesday April 13, 2021 @04:31PM
(#26798840)
Because `0 xfor` is a syntax error regardless -- nowhere in the grammar are you allowed to separate two non-keywords with a space. 0xf is a number, 0xfo is not, so the lexer breaks the token before the o.
This isn't a bug. It's a slightly loose grammar spec that can surprise python users who don't play golf.
This isn't a bug. It's a slightly loose grammar spec that can surprise python users who don't play golf.