[issue21979] SyntaxError not raised on "0xaor 1"
Mark Dickinson
report at bugs.python.org
Mon Jul 14 14:02:44 CEST 2014
Mark Dickinson added the comment:
> Mark, can you explain why the first example is valid syntax, but the second one is not:
Looks like Eric beat me to it! As he explained, it's the "maximal munch" rule at work: the tokenizer matches as much as it can for each token.
You see similar effects with integer or float literals followed by a keyword starting with 'e' (or 'j', but I don't think we have any of those).
>>> 3if 1else 2
File "<stdin>", line 1
3if 1else 2
^
SyntaxError: invalid token
>>> 3if 1 else 2
3
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21979>
_______________________________________
More information about the Python-bugs-list
mailing list