On 1/24/2015 4:51 PM, Marco Buttu wrote:
On 24/01/2015 20:24, Terry Reedy wrote:

On 1/24/2015 5:16 AM, Mario Figueiredo wrote:

Consider the following code at your REPL of choice

        class Sub:
            pass

        foo = Sub()

        Sub.__bases__
        foo.__bases__

The last statement originates the following error:

This is an anomalous situation.

'This situation' being that Someclass.attro works but Someclass().attro raises.

  Normally, if a class has an attribute,

In other words, if 'Someclass.attro' evaluates to an object

instances have the same attribute

then 'Someclass().attro' *normally* evaluates to the same object

(unless overriden).

(unless 'Someclass().attro' has been bound to a different object)
because attribute lookup on an instance reverts to attribute lookup on the class and even its super classes (__bases__). Someclass.__bases__ is special; it is not listed by dir(Someclass), and it is not accessible via an instance.

That is not true:

What I said, as I meant it to be understood, is true.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to