Function mistaken for a method

Eric Brunel eric_brunel at despammed.com
Thu Jun 1 08:37:33 EDT 2006


On Thu, 01 Jun 2006 13:34:53 +0200, Peter Otten <__peter__ at web.de> wrote:

> Eric Brunel wrote:
>
>> My actual question is: why does it work in one case and not in the  
>> other?
>> As I see it, int is just a function with one parameter, and the lambda  
>> is
>> just another one. So why does the first work, and not the second? What
>> 'black magic' takes place so that int is not mistaken for a method in  
>> the
>> first case?
> 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.

Thanks for your explanations, Peter. I'll have to find another way to do  
what I want...
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list