Re: Subclassing Python's dict

2009-08-06 Thread Gabriel Genellina
En Thu, 06 Aug 2009 05:26:22 -0300, Xavier Ho escribió: On Thu, Aug 6, 2009 at 1:19 PM, alex23 wrote: Xavier Ho wrote: > You should subclass collections.UserDict, and not the default dict class. Xavier, why do you think that is the correct approach? I'll be honest first and say that I do

Re: Subclassing Python's dict

2009-08-06 Thread Raymond Hettinger
> Xavier Ho wrote: > > You should subclass collections.UserDict, and not the default dict class. > > Refer to the collections module. > > Xavier, why do you think that is the correct approach? The docs say > "The need for this class has been largely supplanted by the ability to > subclass directly

Re: Subclassing Python's dict

2009-08-06 Thread Raymond Hettinger
> Are you referring to Python 3.0?  Python 2.6 does not have > collections.UserDict In Python2.6, it is in its own module. >>> from UserDict import UserDict Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclassing Python's dict

2009-08-06 Thread Carl Banks
On Aug 5, 7:39 am, Bruno Desthuilliers wrote: > Sergey Simonenko a écrit : > > > Hi, > > > I subclass builtin 'dict' in my application and experience some problems > > with it. > > > The whole issue is that I should redefine 'setdefault' and 'update' > > methods after redefining '__setitem__' or/a

Re: Subclassing Python's dict

2009-08-06 Thread Xavier Ho
On Thu, Aug 6, 2009 at 1:19 PM, alex23 wrote: > Xavier Ho wrote: > > You should subclass collections.UserDict, and not the default dict class. > > Refer to the collections module. > > Xavier, why do you think that is the correct approach? I'll be honest first and say that I do not completely un

Re: Subclassing Python's dict

2009-08-05 Thread alex23
Xavier Ho wrote: > You should subclass collections.UserDict, and not the default dict class. > Refer to the collections module. Xavier, why do you think that is the correct approach? The docs say "The need for this class has been largely supplanted by the ability to subclass directly from dict (a

Re: Subclassing Python's dict

2009-08-05 Thread Xavier Ho
On Thu, Aug 6, 2009 at 5:23 AM, Joshua Kugler wrote: > Are you referring to Python 3.0? Python 2.6 does not have > collections.UserDict > > j > Yes, I was sometimes it's hard to keep track what's not in 2.6 and in 3.1 for me, sorry. And thanks. The ABC MutableMapping is still valid, though.

Re: Subclassing Python's dict

2009-08-05 Thread Joshua Kugler
Xavier Ho wrote: > On Thu, Aug 6, 2009 at 11:51 AM, Sergey Simonenko > wrote: > >> I subclass builtin 'dict' in my application and experience some problems >> with it. >> > > You should subclass collections.UserDict, and not the default dict class. > Refer to the collections module. Are you ref

Re: Subclassing Python's dict

2009-08-05 Thread Bruno Desthuilliers
Sergey Simonenko a écrit : Hi, I subclass builtin 'dict' in my application and experience some problems with it. The whole issue is that I should redefine 'setdefault' and 'update' methods after redefining '__setitem__' or/and '__delitem__', otherwise 'update' and 'setdefault' ignore redefin

Re: Subclassing Python's dict

2009-08-05 Thread Xavier Ho
On Thu, Aug 6, 2009 at 11:51 AM, Sergey Simonenko wrote: > I subclass builtin 'dict' in my application and experience some problems > with it. > You should subclass collections.UserDict, and not the default dict class. Refer to the collections module. Also, the ABC MutableMapping might be of you

Subclassing Python's dict

2009-08-05 Thread Sergey Simonenko
Hi, I subclass builtin 'dict' in my application and experience some problems with it. The whole issue is that I should redefine 'setdefault' and 'update' methods after redefining '__setitem__' or/and '__delitem__', otherwise 'update' and 'setdefault' ignore redefined '__setitem__' and use