Function mistaken for a method

Maric Michaud maric at aristote.info
Thu Jun 1 07:46:16 EDT 2006


Le Jeudi 01 Juin 2006 13:34, Peter Otten a écrit :
> 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.
I don't think it's about c-coded versus python-coded stuff, C1.f is a type, 
C2.f is a method.

In [14]: class t : pass
   ....:

In [15]: class u :
   ....:     f = t
   ....:
   ....:

In [16]: u().f()
Out[16]: <__main__.t instance at 0xa795a9ec>


-- 
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097



More information about the Python-list mailing list