Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32388
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Immutability and Python |
| References | <mailman.3018.1351524004.27098.python-list@python.org> |
| Date | 2012-10-29 08:55 -0700 |
| Message-ID | <7xsj8xl1ct.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
andrea crotti <andrea.crotti.0@gmail.com> writes: > and we want to change its state incrementing the number ... > the immutability purists would instead suggest to do this: > def increment(self): > return NumWrapper(self.number + 1) Immutability purists would say that numbers don't have "state" and if you're trying to change a number's state by incrementing it, that's not immutability. You end up with a rather different programming style than imperative programming, for example using tail recursion (maybe wrapped in an itertools-like higher-order function) instead of indexed loops to iterate over a structure.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Immutability and Python andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-29 15:20 +0000
Re: Immutability and Python Paul Rubin <no.email@nospam.invalid> - 2012-10-29 08:55 -0700
Re: Immutability and Python Chris Angelico <rosuav@gmail.com> - 2012-10-30 03:08 +1100
Re: Immutability and Python andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-29 16:33 +0000
Re: Immutability and Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-29 23:02 +0000
Re: Immutability and Python rusi <rustompmody@gmail.com> - 2012-10-30 09:22 -0700
Re: Immutability and Python Neal Becker <ndbecker2@gmail.com> - 2012-10-30 16:45 -0400
Re: Immutability and Python rusi <rustompmody@gmail.com> - 2012-10-30 20:21 -0700
Re: Immutability and Python Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-11-08 08:38 +0100
csiph-web