[Python-3000] Method descriptors
Guido van Rossum
guido at python.org
Tue Dec 11 18:39:27 CET 2007
On Dec 11, 2007 1:50 AM, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
> I'm not convinced that Python on its own needs it. Perhaps Python
> already distinguishes function-like objects from others rigorously
> enough that they should care about being descriptors themselves.
Right. The use case just doesn't exist.
> CFunction does not define descr_get - why?
Because C functions aren't typically placed in classes defined in
Python -- they enter the world through various tables of function
pointers linked from the type object.
> Maybe it should?
I don't see why we should bother.
I know it would break all sorts of stuff; lots of code stores a
builtin function on a class (for all sorts of reasons), relying on it
not having a __get__ method.
[...]
> I never liked the idea that in Python an instance method is distinguished
> from a class member by the fact of being a function. What if someone
> wants to have a function as a class member? Now Python has staticmethod
> to override this behavior (the method wrapper that we will add or not is
> the overriding in the other direction), but it would be more clean if
> Python distinguished functions from methods since the beginning, e.g.:
>
> method self.foo(args):
> ...
>
> with regular functions not being turned into methods, i.e. being
> staticmethods by default.
Yeah, that won't happen.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list