[Python-Dev] Add a frozendict builtin type

Nick Coghlan ncoghlan at gmail.com
Fri Mar 2 03:06:21 CET 2012


On Fri, Mar 2, 2012 at 11:50 AM, R. David Murray <rdmurray at bitdance.com> wrote:
> +1.  Except in very limited circumstances (such as a security sandbox)
> I would *much* rather have the code I'm interacting with use advisory
> means rather than preventing me from being a consenting adult.  (Having to
> name mangle by hand when someone has used a __ method is painful enough,
> thank you...good thing the need to do that doesn't dome up often (mostly
> only in unit tests)).

The main argument I'm aware of in favour of this kind of enforcement
is that it means you get exceptions at the point of *error* (trying to
modify the "read-only" dict), rather than having a strange
action-at-a-distance data mutation bug to track down.

However, in that case, it's just fine (and in fact better) if there is
a way around the default enforcement via a more verbose spelling.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list