On Tue, 30 Jan 2007 14:39:28 -0300, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>En Tue, 30 Jan 2007 06:34:01 -0300, Beej <[EMAIL PROTECTED]> escribió:
>
>> 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
>
>It appears to be a bug, either in the grammar implementation, or in the
>grammar documentation.
>These are the relevant rules:
>
>attributeref ::= primary "." identifier
>
>primary ::= atom | attributeref | subscription | slicing | call
>
>atom ::= identifier | literal | enclosure
>
>literal ::= stringliteral | integer | longinteger | floatnumber |
>imagnumber
>
>An integer is a primary so 2.__add(1) should be valid.

A float is, too.  2.__add is a float followed by an identifier.
Not legal.  As pointed out elsewhere in the thread, (2). forces
it to be an integer followed by a ".".

Jean-Paul
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to