data attributes override method attributes?
Terry Reedy
tjreedy at udel.edu
Fri Sep 28 14:26:05 EDT 2012
On 9/28/2012 2:02 PM, Prasad, Ramit wrote:
> Just to make sure I am following, if you call
> foo.__len__() it goes to the instance code while
> if you do len(foo) it will go to class.__len__()?
len(foo) calls someclass.__len__(foo) where someclass is foo.__class__or
some superclass.
> If so, why?
Efficiency and perhaps simpler implementation, especially for binary ops.
--
Terry Jan Reedy
More information about the Python-list
mailing list