[issue21979] SyntaxError not raised on "0xaor 1"

Eric V. Smith report at bugs.python.org
Mon Jul 14 13:37:51 CEST 2014


Eric V. Smith added the comment:

To be more clear: the parser takes the longest token that could be valid. Since "n" can't be part of a hex number, parsing stops there, returning "0xaa" as the first token.

So:

>>> 0xaaif 1 else 0
170
>>> hex(0xaaif 1 else 0)
'0xaa'
>>>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21979>
_______________________________________


More information about the Python-bugs-list mailing list