cannot create my own dict

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Sep 19 21:34:29 CEST 2007


Bruno Desthuilliers a écrit :
> A.T.Hofkamp a écrit :
> 
(snip)

>> # Below is produced with
>> # print '\n'.join(['        self.%s = self.mydict.%s' % (v,v)
>> #                                         for v in dir(dict)])
>> # commented-out functions done by hand
>> #
>>         #self.__class__ = self.mydict.__class__
>>         self.__cmp__ = self.mydict.__cmp__
>>         self.__contains__ = self.mydict.__contains__
> 
> 
> (snip lots of useless code)
> 
> May I suggest that you learn to use __getattr__ and __setattr__ ?-)

Mmmm... Should have tested before posting this. Please ignore this 
remark, looks like __getattr__ is not called for __magic__ methods. Doh :(




More information about the Python-list mailing list