Confused with methods
Alex Martelli
aleaxit at yahoo.com
Mon Feb 7 09:24:11 EST 2005
Antoon Pardon <apardon at forel.vub.ac.be> wrote:
> Op 2005-02-06, Alex Martelli schreef <aleaxit at yahoo.com>:
> >
> >> 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.
Alex
More information about the Python-list
mailing list