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
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
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
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
[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.
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
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