data attributes override method attributes?

Ian Kelly ian.g.kelly at gmail.com
Tue Sep 25 16:07:58 EDT 2012


On Tue, Sep 25, 2012 at 1:58 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 9/25/2012 11:03 AM, Chris Angelico wrote:
>> Instance attributes override (shadow) class attributes.
>
>
> except for (some? all?) special methods

Those names are shadowed too.  If you call foo.__len__() and the name
is bound on the instance, it will call that function preferentially.
It's just that when the special Python machinery calls the method, it
skips the instance and goes straight to the class.



More information about the Python-list mailing list