This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients eric.smith, mark.dickinson, mel
Date 2014-07-14.12:02:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405339364.35.0.112322582881.issue21979@psf.upfronthosting.co.za>
In-reply-to
Content
> 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
History
Date User Action Args
2014-07-14 12:02:44mark.dickinsonsetrecipients: + mark.dickinson, mel, eric.smith
2014-07-14 12:02:44mark.dickinsonsetmessageid: <1405339364.35.0.112322582881.issue21979@psf.upfronthosting.co.za>
2014-07-14 12:02:44mark.dickinsonlinkissue21979 messages
2014-07-14 12:02:44mark.dickinsoncreate