is it a bug ?

Sylvain Ferriol sferriol at imag.fr
Mon Oct 23 05:29:08 EDT 2006


Fredrik Lundh a écrit :
> Sylvain Ferriol wrote:
> 
>> can you explain to me what happened:
>>
>> class toto(object):
>>    eq = float.__eq__
>>
>> t = toto()
>>
>> getattr(t,'eq')
>> TypeError: descriptor '__eq__' for 'float' objects doesn't apply to 
>> 'toto' object
> 
> 
> I'd say the error message explains it pretty well.  what did you expect 
> this to do?
> 
i just want a class variable named 'eq', i could understand if its name 
was '__eq__'.
class toto(object):
   __eq__ = float.__eq__

why i can not create some class variables like this ?
class toto(object):
   a= float.__eq__
   b= str.__eq__
   ......



> </F>
> 



More information about the Python-list mailing list