[Python-ideas] Support other dict types for type.__dict__
Rob Cliffe
rob.cliffe at btinternet.com
Mon Feb 27 19:35:57 CET 2012
On 27/02/2012 18:32, Mark Janssen wrote:
> 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.
>
> mark
> Santa Fe, NM
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
I suggested a "mutable" attribute some time ago.
This could lead to finally doing away with one of Python's FAQs: Why
does python have lists AND tuples? They could be unified into a single
type.
Rob Cliffe.
More information about the Python-ideas
mailing list