Amaury Forgeot d'Arc added the comment:

This is expected. When you assign to "n.__div__" a function which takes two 
parameters, you have to call it with two parameters:

    aFunction = lambda x, y: (x, y)
    n.__div__ = aFunction
    aFunction(1, 2)
    n.__div__(1, 2)

After all, aFunction and n.__div__ are the same object.
Now, it would be different if you had attached the function to the *class* 
instead:

    n.__class__.__div__ = aFunction
    n.__div__(2)   # returns (n, 2)

In this second example, n.__div__ is a bound method; the first parameter 
(usually named "self") is already filled, and only the second one is required.

----------
nosy: +amaury.forgeotdarc
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18474>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to