Re: Making immutable instances



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.

.



Relevant Pages

  • New to Python: Features
    ... I'm new to Python and I'd like to know if Python has the following ... Operator overloading (inc. the ability to define new operators) ... Support for unplanned reuse of classes such as in TOM ... puts "Now that's acceptable" ...
    (comp.lang.python)
  • Re: Recursive directory listing
    ... look at the source for the similar function/method of Python (I think ... Peter Seebach said in his first reply to your post - a file tree walk ... function pointer to it, via which the function pointed to, gets called ... Providing the ability to ...
    (comp.lang.ruby)
  • Re: Nominations for funniest post of the year on umtm
    ... >>> If you think you can write something wittier than my Mullen and Python ... > You're one of those very common people who criticises others - ... Just because a person does not have the ability to do something does not ...
    (uk.media.tv.misc)
  • Re: how to modify code while debugging it without having to stop and then restart debugger
    ... The ability to step through code line by line was very useful in a ... However I have to say that since using Python, ... > i own and run a small programming company and there is one feature that keeps me in the windows/basic world. ... > so how can i use python to debug code and change that code without having to restart the code. ...
    (comp.lang.python)
  • Re: Making immutable instances
    ... > with messing with private variables. ... analogous to the name mangling that Python does: ... the class designer didn't want me adding attributes to instances... ...
    (comp.lang.python)