Method binding confusion

Andrew Bennetts andrew-pythonlist at puzzling.org
Mon May 3 03:44:14 EDT 2004


On Sun, May 02, 2004 at 11:57:26PM -0700, A B Carter wrote:
> I'm a bit confused by the behavior of the following code:
[...]
> 
> The last call fails with "TypeError: takes exactly 2 argumetns (3
> given)" I understand that in KlassMyModule the operator is being
> treated as a method and a reference to the class instance is being
> past as the first argument. And I also understand that Python is
> treating a function from the standard math libary differently from a
> function I defined in my own module. What I don't understand is why.

Builtin functions aren't descriptors; in particular, they don't have the
method-wrapping magic in their __get__ that ordinary (i.e. pure-python)
function objects do.

See http://users.rcn.com/python/download/Descriptor.htm, particularly the
section on Functions and Methods.

-Andrew.





More information about the Python-list mailing list