[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread James Lu
New submission from James Lu: if you assign a lambda to a object and call it,you get this: Traceback (most recent call last): File pyshell#21, line 1, in module n.__div__(3) TypeError: lambda() takes exactly 2 arguments (1 given) The full test is here: n = num() n.__div__ function lambda

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread James Lu
Changes by James Lu jam...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18474 ___ ___ Python-bugs-list mailing

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread Brett Cannon
Brett Cannon added the comment: What version of Python is this and did you assign the lambda to an instance or class (and if this is Python 2, new-style or classic class)? -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread James Lu
James Lu added the comment: 2.5,new-style -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18474 ___ ___ Python-bugs-list mailing list

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread James Lu
James Lu added the comment: instance,assinged during __init__ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18474 ___ ___ Python-bugs-list

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread James Lu
James Lu added the comment: Also,there were some bugs, but after I fixed them, it would only work if I did this: n.__div__(n,3) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18474 ___

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: Could you provide an entire example, showing the class num and how you assign __div__? -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18474

[issue18474] Lambda assigned to object does not automatically get self

2013-07-16 Thread Amaury Forgeot d'Arc
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