Re: Making immutable instances



On Fri, 25 Nov 2005 23:20:05 -0500, Mike Meyer wrote:

> Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxx> writes:
>> "Hmmm, the class designer didn't want me adding attributes to instances...
>> maybe he had a good reason for that..."
>
> When it was suggested that a facility for doing this be added to the
> language, I asked for a use case for it. Nobodies come up with a
> reason for placing such restriction on the client yet.

Oh, I think it is terribly unfair to call them nobodies, even if you don't
like their use-cases *grin*

> If you've got a use case, I'd be interested in hearing it.

frozenset perhaps? If it were needed once, it could be needed again.

The obvious case would be for a class where distinct instances that
compare equal but not identical map to the same value in a dict.

In any case, I'm not the one claiming that I need custom immutable
classes. I'm just suggesting that there is nothing non-Pythonic about
them. If Ben thinks he needs them, I'm sure he has put *far* more thought
into it than I have. I know Ben in RL, and he is not someone to make snap
judgements about turning Python into Some Other Language Just Because.


--
Steven.

.



Relevant Pages

  • Re: Giving an application a window icon in a sensible way
    ... unless you're suggesting either that I should have ... reason beyond the sheer joy of criticizing someone. ... PriorityQueue and seeing in the regular-F2 window the PriorityQueue ... When I use a copy of Eclipse without the core Java documentation ...
    (comp.lang.java.programmer)
  • Re: Bold numbers in ordered lists
    ... Yes it is OK in the special sense, but does that make it OK? ... I am not suggesting anyone should call an ol a table or a specially ... list whenever an author feels like it for no particular good reason. ... You are basically saying I am completely wrong about the most crucial ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: Merchant Princes. was: Re: What Book are you reading now?
    ... world seems to be considered a top-security secret. ... I'm not suggesting it is. ... Miriam's citizenship status wasn't simply assumed on the basis of her ... it could be invoked as a reason to confine her -- if the ...
    (rec.arts.sf.written)
  • Re: We are in a war to the death - Janet Daley
    ... Half of Europe - the half that was so smug ... I wonder if the Pope will differentiate. ... reason or otherwise.. ... He's suggesting a redefinition of reason in order to accommodate faith, ...
    (uk.politics.misc)