Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93513 > unrolled thread
| Started by | Robert Kern <robert.kern@gmail.com> |
|---|---|
| First post | 2015-07-06 00:44 +0100 |
| Last post | 2015-07-06 00:44 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: (side-)effects and ... Robert Kern <robert.kern@gmail.com> - 2015-07-06 00:44 +0100
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Date | 2015-07-06 00:44 +0100 |
| Subject | Re: (side-)effects and ... |
| Message-ID | <mailman.309.1436139866.3674.python-list@python.org> |
On 2015-07-05 21:36, Tim Chase wrote: > On 2015-07-05 20:29, Stefan Ram wrote: >> But why do we not have a common and well-known term for >> the counterpart, that something does not modify the state >> of the world, but that the state of the world does >> influence the value (behaviour) of a call such as >> »datetime.datetime.now().time()«? > > I believe the term is "idempotent" > > https://en.wikipedia.org/wiki/Idempotent_function#Computer_science_meaning No, "idempotent" means that if it changes the state, then applying it twice or more has the same effect as applying it once. For example, calling object.__setattr__(self, attr, y) with the same arguments is idempotent; whether you execute that once, twice or N times, afterwards, `getattr(self, attr) is y`. But calling it the first time probably did make a change of state. This is unlike functions like list.append(self, x) which will give you different results depending on the number of times you call it, even if the arguments are the same. Functions that don't change state at all are naturally idempotent, but many idempotent functions do change state. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Back to top | Article view | comp.lang.python
csiph-web