Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'value,': 0.04; '(all': 0.07; 'defaults': 0.07; 'float': 0.07; 'variables.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'changes': 0.15; 'bind': 0.16; 'fiddle': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'placed.': 0.16; 'scope,': 0.16; 'stem': 0.16; 'subject:variable': 0.16; 'variable.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'wed,': 0.18; '(in': 0.22; 'reset': 0.22; 'cc:addr:python.org': 0.22; '2.2': 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'values': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'thus': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'decimal': 0.31; 'languages': 0.32; 'another': 0.32; 'basic': 0.35; "can't": 0.35; 'common': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'object,': 0.36; 'sequence': 0.36; 'fact': 0.38; 'does': 0.39; 'delete': 0.39; 'name': 0.63; 'more': 0.64; 'relatively': 0.65; 'between': 0.67; 'results': 0.69; 'apart': 0.72; '7:00': 0.84; 'mechanics': 0.84; 'mean.': 0.91; 'to:none': 0.92; 'differences': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=3Nw7tVaaeVz8y/1gg1hY8RvEnn+dfRX+1AzRXWiMXZI=; b=Z8BeD7z6P4tnhpUuKNpEUK78o/4dkkp/lKwijsvIRDyWosf56Dn4CD5itxmbPvzz2W 4TBvHFKcQolHmWfGu3Kqlz+oKcQ/gSWRByqJE5fhMirxKZS4zyFogNtH4yEqdSWEtdUh KEw/JLB8WXf24v/YxXb0YGwePkTGy04dPf60RKUZNiKqzI6rE7us6L2wpwTM5BCyQSqZ ympqxl7SYWjg9i0u+o4TXMMf5I9AnNf6EUr+DpvyoX66yfLviCmCoLroSG3BLQ78znMx 3SwQahQVaZQpQdV23jviiJoyC2RrrYz1P9xHIbMyVsAhNuUhZPVuC0uy5mXfVxqtIv2F Pkmg== MIME-Version: 1.0 X-Received: by 10.52.255.65 with SMTP id ao1mr2786648vdd.43.1399419976384; Tue, 06 May 2014 16:46:16 -0700 (PDT) In-Reply-To: References: <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> <5368681D.8070602@islandtraining.com> Date: Wed, 7 May 2014 09:46:16 +1000 Subject: Re: Pass variable by reference From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399419985 news.xs4all.nl 2886 [2001:888:2000:d::a6]:57814 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70990 On Wed, May 7, 2014 at 7:00 AM, Mark H Harris wrote: > What does the word "variable" mean. Think BASIC variables. You can set them, > you can reset them, you can delete them, you can change them. ... because > they are variable. > > Python has names bound to objects... some of which you may not change. Once > the name is bound to an object you may bind it to another object, but you > may not change it, nor may you change the object it is bound to if the > object is immutable. Is this code mutating or rebinding? x = 1.1 y = 2.2 x = x + y What language did I write that in? Is there really a fundamental difference between languages in which that is equally valid syntax and does exactly the same thing? Apart from the fact that BASIC defaults to single-precision float (in the absence of a hash suffix), Python uses double-precision, and REXX uses decimal strings, this sequence will work identically in all of them. Does BASIC have variables? Presumably, since you can pass them by reference. Does REXX? You can't pass by reference (all you can do is EXPOSE, which is more like scoping rules, only it isn't); a C function can fiddle with any named variable in its caller's scope, so a common way to "return" multiple values is to pass the name of a stem (which isn't an array, and isn't a dict/mapping, and isn't really an object at all) into which the results will be placed. Python has objects and names, and changes which object a name is bound to. The mechanics differ, but fundamentally, x started out as 1.1 and ended up as 3.3. That means x varied in value, and is thus a variable. The differences are relatively insignificant. ChrisA