Help me understand this
Diez B. Roggisch
deets at nospam.web.de
Tue Jan 30 04:38:04 EST 2007
Beej wrote:
> On Jan 29, 11:47 pm, Steven D'Aprano
> <s... at REMOVEME.cybersource.com.au> wrote:
>> Outside of a print statement (and also an "except" statement), commas
>> create tuples.
>
> And function calls:
>
>>>> 3,
> (3,)
>>>> type(3,)
> <type 'int'>
>>>> type((3,))
> <type 'tuple'>
>
> But here's one I still don't get:
>
>>>> type(2)
> <type 'int'>
>>>> type((2))
> <type 'int'>
>>>> (2).__add__(1)
> 3
>>>> 2.__add__(1)
> File "<stdin>", line 1
> 2.__add__(1)
> ^
> SyntaxError: invalid syntax
Because 2. is the start of a float-literal. That isn't distinguishable for
the parsere otherwise.
Diez
More information about the Python-list
mailing list