Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32391
| References | <CAF_E5Jbf0KJjDLV0jS-p_J9E4D8=_sPScgE+vkmkN2sMw=3aoA@mail.gmail.com> <1793477354.3492917.1351526431192.JavaMail.root@sequans.com> |
|---|---|
| Date | 2012-10-29 16:12 +0000 |
| Subject | Re: Immutability and Python |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3025.1351527152.27098.python-list@python.org> (permalink) |
2012/10/29 Jean-Michel Pichavant <jeanmichel@sequans.com>:
>
>
> In an OOP language num.increment() is expected to modify the object in place.
> So I think you're right when you say that functional languages technics do not necessarily apply to Python, because they don't.
>
> I would add that what you're trying to suggest in the first post was not really about immutability, immutable objects in python are ... well immutable, they can be used as a dict key for instance, your NumWrapper object cannot.
>
>
> JM
Yes right immutable was not the right word, I meant that as a contract
with myself I'm never going to modify its state.
Also because how doi I make an immutable object in pure Python?
But the example with the dictionary is not correct though, because this:
In [145]: class C(object):
.....: def __hash__(self):
.....: return 42
.....:
In [146]: d = {C(): 1}
works perfectly, but an object of class C can mutate as much as it
wants, as my NumWrapper instance..
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Immutability and Python andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-29 16:12 +0000
Re: Immutability and Python Paul Rubin <no.email@nospam.invalid> - 2012-10-29 09:46 -0700
Re: Immutability and Python andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-29 17:05 +0000
Re: Immutability and Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-29 22:30 +0000
Re: Immutability and Python Chris Kaynor <ckaynor@zindagigames.com> - 2012-10-29 15:45 -0700
Re: Immutability and Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-29 23:14 +0000
Re: Re: Immutability and Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-10-29 12:58 -0500
Re: Immutability and Python Terry Reedy <tjreedy@udel.edu> - 2012-10-29 14:03 -0400
Re: Immutability and Python Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-10-29 14:25 -0400
csiph-web