Re: Dictionary inheritance

2005-08-13 Thread Elmo Mäntynen
On Fri, 12 Aug 2005 12:44:11 -0700, Talin wrote: > I want to make a dictionary that acts like a class, in other words, > supports inheritance: If you attempt to find a key that isn't present, > it searches a "base" dictionary, which in turn searches its base, and so on. > > Now, I realize its f

Re: Dictionary inheritance

2005-08-13 Thread bruno modulix
Talin wrote: > I want to make a dictionary that acts like a class, in other words, > supports inheritance: I must be missing your point here, since dict is a class and as such support inheritence: >>> class MyDict(dict):pass ... >>> d = MyDict() >>> d.items() [] >>> > If you attempt to find a

Re: Dictionary inheritance

2005-08-13 Thread bruno modulix
Devan L wrote: > Talin wrote: > >>I want to make a dictionary that acts like a class, in other words, >>supports inheritance: (snip) > > Dictionaries aren't classes? They are. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECT

Re: Dictionary inheritance

2005-08-12 Thread Jordan Rastrick
Talin asked: > Also, on a completely different subject: Has there been much discussion > about extending the use of the 'is' keyword to do type comparisons a la > C# (e.g. "if x is list:") ? > > -- Talin No, is already has a specific, well defined meaning - object identity. IDLE 1.1 >>> a = [1,2

Re: Dictionary inheritance

2005-08-12 Thread Raymond Hettinger
[Talin] > I want to make a dictionary that acts like a class, in other words, > supports inheritance: If you attempt to find a key that isn't present, > it searches a "base" dictionary, which in turn searches its base, and so on. Perhaps the chainmap() recipe will meet your needs: http://aspn.

Re: Dictionary inheritance

2005-08-12 Thread Devan L
Talin wrote: > I want to make a dictionary that acts like a class, in other words, > supports inheritance: If you attempt to find a key that isn't present, > it searches a "base" dictionary, which in turn searches its base, and so on. > > Now, I realize its fairly trivial to code something like thi

Dictionary inheritance

2005-08-12 Thread Talin
I want to make a dictionary that acts like a class, in other words, supports inheritance: If you attempt to find a key that isn't present, it searches a "base" dictionary, which in turn searches its base, and so on. Now, I realize its fairly trivial to code something like this using UserDict, b