On Wed, Oct 07, 2015 at 04:10:20PM +, Albert-Jan Roskam wrote:
> Hi,
> I wanted to create a read-only dict to hold some constants. I looked around
> on the internet and created two implementations:-FrozenDict (derives from
> collections.mapping)-ChillyDict (derives from dict, which seems more
Hi Albert-Jan,
As far as I know, the recommended object to subclass when subclassing a `dict`
is `UserDict`. In Python 3, it's in `collections.UserDict` and in Python 2 is
in `UserDict.UserDict`.
Here's an basic example of how it would work:
try:
from collections import UserDict
except Impo
> From: sjeik_ap...@hotmail.com
> To: tutor@python.org
> Date: Wed, 7 Oct 2015 16:10:20 +
> Subject: [Tutor] FrozenDict
>
> Hi,
> I wanted to create a read-only dict to hold some constants. I looked around
> on the internet and created two implementations:-FrozenDict (derives from
> collecti
Hi,
I wanted to create a read-only dict to hold some constants. I looked around on
the internet and created two implementations:-FrozenDict (derives from
collections.mapping)-ChillyDict (derives from dict, which seems more obvious to
me)
The code can be found here: http://pastebin.com/QJ3V2mSK
S