Re: Making immutable instances
- From: Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 26 Nov 2005 12:08:15 +1100
On Thu, 24 Nov 2005 11:44:16 -0500, Mike Meyer wrote:
> In Python, I can even fix
> it so *your* code uses my wrapped version:
>
> import Finney
> class Addable(Finnney.Immutable): pass
> Finney.Immutable = Addable
>
> Which means that from now on *your* code that tries to create
> Immutables will actually get Addables. The inability to do this in B&D
> languages is - well, painfull. That Python doesns't require the
> boilerplate in a good thing.
The ability to shoot yourself in the foot *if you want to* is a feature,
not a bug. But the ability to shoot yourself in the foot *accidentally* is
not a feature.
I am happy that whatever restrictions the class designer builds on their
class is easy to bypass, because the class designer is not omniscient
and their "private data" may be just the thing I need to solve a
problem some day. But I should have to *think about it* before messing
about with it.
Python's consenting adults philosophy allows the class designer some
limited ability to force the class user to think about it before messing
about with private variables. I think Ben's immutable class falls into
that same category.
--
Steven.
.
- Follow-Ups:
- Re: Making immutable instances
- From: Mike Meyer
- Re: Making immutable instances
- References:
- Making immutable instances
- From: Ben Finney
- Re: Making immutable instances
- From: Alex Martelli
- Re: Making immutable instances
- From: Ben Finney
- Re: Making immutable instances
- From: Alex Martelli
- Re: Making immutable instances
- From: Ben Finney
- Re: Making immutable instances
- From: Mike Meyer
- Making immutable instances
- Prev by Date: Re: wxPython Licence vs GPL
- Next by Date: Re: Unicode in MIMEText
- Previous by thread: Re: Making immutable instances
- Next by thread: Re: Making immutable instances
- Index(es):
Relevant Pages
|
|