Re: Making immutable instances
- From: Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx>
- Date: Thu, 24 Nov 2005 15:39:02 +1100 (EST)
Alex Martelli <aleax@xxxxxxxxxxxxxxxx> wrote:
> Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx> wrote:
> > How can a (user-defined) class ensure that its instances are
> > immutable, like an int or a tuple, without inheriting from those
> > types?
>
> [...]
> Of course, these restrictions can be easily worked around by a
> sufficiently determined attacker... but if you have to think of the
> user of your code as an attacker, you've got worse problems than
> this trifling one.
I've probably stumbled across something that people often want to do
for ill-considered reasons; I don't really understand the reaction I'm
getting.
Why is "I want to make objects immutable" seen as "I don't trust my
users"? Are Python's existing immutable types also seen the same way?
If not, why the distinction?
For context, I'm intending for the immutability of class instances to
be a properly documented part of the class protocol. Does that sound
more reasonable?
--
\ "In general my children refuse to eat anything that hasn't |
`\ danced on television." -- Erma Bombeck |
_o__) |
Ben Finney
.
- Follow-Ups:
- Re: Making immutable instances
- From: Alex Martelli
- Re: Making immutable instances
- References:
- Making immutable instances
- From: Ben Finney
- Re: Making immutable instances
- From: Alex Martelli
- Making immutable instances
- Prev by Date: Re: Python as Guido Intended
- Next by Date: Re: Why are there no ordered dictionaries?
- Previous by thread: Re: Making immutable instances
- Next by thread: Re: Making immutable instances
- Index(es):