On 07/10/2010 11:42, kj wrote:
In<mailman.1415.1286438617.29448.python-l...@python.org> Terry
Reedy<tjre...@udel.edu> writes:
If these two attributes, and hence the dicts, are public, then your
instances are mutable.
I guess I should have written "immutable among consenting adults."
As far as I know, Python does not support private attributes, so
I guess the dicts are public no matter what I do. I suppose that
I can implement "frozendict", but I can't think of any way to
enforce the immutability of these "frozendicts" that would not be
trivial to circumvent (it better be, in fact, otherwise I wouldn't
be able to initialize the damn things).
You would initialise them by creating them from a list of tuples (or an
iterable which yields tuples), like with a dict:
>>> dict([(1, "foo"), (2, "bar")])
{1: 'foo', 2: 'bar'}
--
http://mail.python.org/mailman/listinfo/python-list