>>> 1 .__hash__()
1
>>> 1.__hash__()
File "<stdin>", line 1
1.__hash__()
^
SyntaxError: invalid syntax
It has been covered here before that the second example doesn't work because the int literal is actually parsed as a float.
My question is, why doesn't python parse this as attribute access on an int, when the interpretation as a float is a syntax error? The docs section on lexical analysis seem to suggest whitespace only required when other interpretations are ambiguous, but perhaps I'm reading this section wrong.
On a hunch it seems like the lexer is greedy (trying to take the biggest token possible), but I have no source for this claim.