[Python-ideas] Support other dict types for type.__dict__

Mark Janssen dreamingforward at gmail.com
Mon Feb 27 19:32:05 CET 2012

On Sat, Feb 25, 2012 at 4:05 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Ned Batchelder wrote:
>> The Python answer for people who want read-only data structures has always
>> been, "Don't modify them if you don't want to, and write docs that tell
>> other people not to as well."  What are you building that this answer isn't
>> good enough?
> That is silly. That alleged "Python answer" is like telling people that they
> don't need test frameworks or debuggers because the "Python answer" for
> people wanting to debug their code is not to write buggy code in the first
> place.

Perhaps a good middle ground for this is to NOT tie it to particular
data structures (like tuples vs lists), but abstract it by making an
"immutable bit" that is part of the basic Object type.  This doesn't
give complete security, but does *force* a choice by a human agent to
deliberately modify data.  (This was actually going to be implemented
in a sort of python fork several years ago.)  There could be a
"mutable?" check that returns True or False.

Santa Fe, NM

More information about the Python-ideas mailing list