Op 2005-02-07, Alex Martelli schreef <[EMAIL PROTECTED]>: > Antoon Pardon <[EMAIL PROTECTED]> wrote: > >> Op 2005-02-06, Alex Martelli schreef <[EMAIL PROTECTED]>: >> > >> >> Isn't that inconsistent? >> > >> > That Python has many callable types, not all of which are descriptors? >> > I don't see any inconsistency there. Sure, a more generalized currying >> > (argument-prebinding) capability would be more powerful, but not more >> > consistent (there's a PEP about that, I believe). >> >> I think python is a bit inconsistent here, by using 'def' for >> two different things. > > It doesn't. > >> I think it would have been more consistent >> if def always produces a function > > It does. > > def g(self): pass > class A(object): > f = g > > class B(object): > def f(self): pass > > class C(object): pass > C.f = g > > class D(object): > f = B.f > > These four classes are essentially equivalent. def always produces a > function object and binds it to the name coming after keyword 'def'. > Any such function object, no matter how produced and how bound hither > and thither, always behaves in exactly the same way. > > You're free to like or dislike this arrangement, but calling it > "inconsistent" is a madman's folly, as it is TOTALLY consistent.
Yes it is inconsistent with the rest of python. That you found a subset in which it is consistent doesn't change that. And what if you do: c = C() c.f = g The fact that a function in a class performs a lot of magic if it is called through an instance, that isn't performed otherwise, makes python inconsistent here. You may like the arrangement (and it isn't such a big deal IMO) but that doesn't make it consistent. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list