Why not 3.__class__ ?

Andrew Dalke dalke at dalkescientific.com
Wed Oct 10 13:24:08 EDT 2001


Michael Abbott wrote:
>More to the point, I don't see any room for any
>bugs at all here (let alone obscure ones), since the offending syntax is
>caught by the "compiler".

Suppose there's an attribute named 'j'.  Under current Python

>>> 3.j
3j
>>> 3. j
  File "<stdin>", line 1
    3. j
       ^
SyntaxError: invalid syntax
>>>

If the space is allowed as shorthand for getattr(3, "j") then
there is a chance for obscure bugs.  But I've never seen
anyone who even considered the idea of methods or attributes on
numbers in Python (note the "in Python") excepting those few
that come from Smalltalk or Ruby backgrounds.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list