On Nov 26, 2007 3:49 PM, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Nick Coghlan wrote:
> > Interestly, I just discovered that method descriptors for builtins don't
> > define im_class, im_self or im_func. I never knew that - I thought they
> > had the same interface as instance methods.
>
> A builtin method descriptor is the C equivalent of a
> function object, not an instancemethod.

Not quite -- it holds a reference to an object too.

> The desired behaviour would be for builtin method
> descriptors to have a __get__ method that creates
> an instancemethod object, like functions do.

They have that too. See:

Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = []
>>> f = list.append
>>> f
<method 'append' of 'list' objects>
>>> g = f.__get__(a)
>>> g
<built-in method append of list object at 0x590f8>
>>> a.append
<built-in method append of list object at 0x590f8>
>>> g(42)
>>> a
[42]
>>>

What am I missing?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to