Peter Otten wrote: > Eric Brunel wrote: > > >>My actual question is: why does it work in one case and not in the other? >>As I see it, int is just a function with one parameter, and the lambda is >>just another one. So why does the first work, and not the second? What >>'black magic' takes place so that int is not mistaken for a method in the >>first case? > > > A python-coded function has a __get__ attribute, a C-function doesn't. > Therefore C1.f performs just the normal attribute lookup while C2.f also > triggers the f.__get__(C2(), C2) call via the descriptor protocol which > happens to return a bound method.
FWIW: class Obj(object): def __new__(cls, val, *args, **kw): print "in Obj.__new__" print "- called with :" print " cls :", cls print " val :", val print " args:", str(args) print " kw :", kw obj = object.__new__(cls, *args, **kw) print "got : %s - %s" % (obj, dir(obj)) return obj class CPlus(C): f = Obj > Peter > > -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list