function call syntax oddity
All, I was showing a co-worker some python today (using the trunk) when I stumbled upon this. I was not sure what to think since I have never really experimented with using spaces like this. So here tis. Be careful to notice the spaces as they are significant here.
1.3.__str__() '1.3'
1.3 .__str__() '1.3'
a = " somestring "
a .split() ['somestring']
a. split() ['somestring']
Cool I suppose, except here's an odd man out:
1.__str__() File "<stdin>", line 1 1.__str__() ^ SyntaxError: invalid syntax
1 .__str__() '1'
Joseph Armbruster
On 04/01/2008, Joseph Armbruster <josepharmbruster@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.
participants (2)
-
Joseph Armbruster -
Paul Moore