class or inherited list ?

Stef Mientki stef.mientki at gmail.com
Fri Mar 28 19:02:27 CET 2008


>>>
>>> class super_list(list):
>>>     pass
>>>
>>> def kwadraat ( value ) :
>>>     return value * value
>>>
>>> x={}
>>> x['frequency']=33
>>> x['functie']=kwadraat
>>> print x['functie'](2)
>>>
>>> y = super_list()
>>> y.frequency = 33
>>> y.functie = kwadraat
>>> print y.functie(3)
>>>     
>>
>> You don't use y as a list at all - you might as well inherit from 
>> object.
> Good point, didn't notice that.
Sorry, not a good point,
by deriving from a list, I get all the list methods for nothing.

cheers,
Stef Mientki




More information about the Python-list mailing list