[Python-Dev] function call syntax oddity
Paul Moore
p.f.moore at gmail.com
Fri Jan 4 22:32:44 CET 2008
On 04/01/2008, Joseph Armbruster <josepharmbruster at gmail.com> wrote:
> Cool I suppose, except here's an odd man out:
>
> >>> 1.__str__()
> File "<stdin>", line 1
> 1.__str__()
> ^
> SyntaxError: invalid syntax
It's parsed a floating point number - "1." - followed by the keyword
"__str__". That's not valid.
> >>> 1 .__str__()
> '1'
This one is a number "1" followed by the operator "." followed by "__str__".
The lexer reads the longest valid token each time.
Paul.
More information about the Python-Dev
mailing list