On 9/25/2012 4:07 PM, Ian Kelly wrote:
On Tue, Sep 25, 2012 at 1:58 PM, Terry Reedy <tjre...@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.
I added "Ian Kelly reminds me that instance.__xxx__ is only skipped by
the internal machinery and not by direct accesses in user code. In the
other hand, docs, official or otherwise, are filled with things like
'len(a) calls a.__len__', so I think something should be said that
giving instances special method attributes does not have the effect one
might expect."
to the issue.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list