Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'modify': 0.04; 'naturally': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'underlying': 0.09; 'times,': 0.13; '21:36,': 0.16; 'kern': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'well-known': 0.16; 'wrote:': 0.16; 'skip:` 10': 0.18; 'stefan': 0.18; 'changes': 0.20; 'arguments': 0.22; 'interpret': 0.22; 'unlike': 0.23; 'header:In-Reply-To:1': 0.24; 'tim': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'chase': 0.29; 'once,': 0.29; 'once.': 0.29; 'url:wikipedia': 0.29; 'no,': 0.29; 'url:wiki': 0.30; 'probably': 0.32; 'common': 0.33; 'ram': 0.33; 'to:addr:python-list': 0.35; 'attempt': 0.35; 'robert': 0.35; 'something': 0.35; 'skip:o 20': 0.35; 'but': 0.36; 'url:org': 0.36; 'world,': 0.38; 'received:org': 0.38; 'means': 0.39; 'url:en': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'why': 0.40; 'term': 0.60; 'even': 0.61; 'times': 0.61; 'more': 0.62; 'different': 0.64; 'world': 0.64; 'our': 0.64; 'results': 0.66; 'state,': 0.66; 'believe': 0.67; 'state.': 0.72; 'applying': 0.73; 'eco': 0.84; 'subject: ...': 0.84; 'terrible': 0.84; 'received:86': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: (side-)effects and ... Date: Mon, 06 Jul 2015 00:44:19 +0100 References: <20150705153625.263a3b21@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: cpc5-cmbg17-2-0-cust789.5-4.cable.virginm.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <20150705153625.263a3b21@bigbox.christie.dr> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436139866 news.xs4all.nl 2936 [2001:888:2000:d::a6]:36828 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.91.MISMATCH!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:93513 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