Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'subject:Python': 0.06; 'assign': 0.07; 'variables': 0.07; 'bindings': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'variable,': 0.09; 'variables.': 0.09; '\xe2\x80\x94': 0.09; 'python': 0.11; 'finney': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sense,': 0.16; 'subject:?)': 0.16; 'subject:variable': 0.16; 'track.': 0.16; 'wider': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'community,': 0.19; "python's": 0.19; 'small,': 0.19; 'later': 0.20; 'appears': 0.22; 'programming': 0.22; 'header:User- Agent:1': 0.23; 'references': 0.26; 'pass': 0.26; 'header:X -Complaints-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'values.': 0.31; 'writes:': 0.31; 'quite': 0.32; 'plain': 0.33; 'subject: (': 0.35; 'agree': 0.35; 'something': 0.35; 'but': 0.35; 'really': 0.36; 'false': 0.36; 'leads': 0.36; 'received:com.au': 0.36; 'view,': 0.36; 'so,': 0.37; 'clear': 0.37; 'ben': 0.38; 'to:addr :python-list': 0.38; 'fact': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'subject:Can': 0.60; 'simple': 0.61; "you've": 0.63; 'term': 0.63; 'more': 0.64; 'different': 0.65; 'skip:\xe2 10': 0.65; 'mar': 0.68; '8bit%:40': 0.68; 'sam': 0.68; '8bit%:43': 0.74; 'carefully': 0.74; 'special': 0.74; '8bit%:46': 0.78; 'batchelder': 0.84; 'implications': 0.84; 'kennedy': 0.84; 'received:125': 0.84; 'understand,': 0.84; 'hate': 0.91; 'philips': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Python and variables (was: Can global variable be passed into Python function?) Date: Sat, 22 Feb 2014 11:13:44 +1100 References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <87sird7wuw.fsf@handshake.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: vmx15867.hosting24.com.au X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:hbL6cqGeXQqPMb1idSiWV+C+v9g= 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393028041 news.xs4all.nl 2977 [2001:888:2000:d::a6]:54195 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66859 Ned Batchelder writes: > On 2/21/14 2:23 AM, dieter wrote: > > Sam writes: > > > >> >I need to pass a global variable into a python function. > > Python does not really have the concept "variable". > > > > What appears to be a variable is in fact only the binding of an > > object to a name. If you assign something to a variable, > > all you do is binding a different object to the name. > > > > Man, do I hate this idea that Python has no variables. I agree with the sentiment of you've quoted from “dieter”, above. But I also agree with your sentiment. I think it's misleading to use the term “variable” to describe what Python has, because that term has an unavoidable collection of implications in the wider programming community, and many of those implications are plain false for Python. I think it's misleading to claim Python “has no variables” — which is not quite the same as what “dieter” claimed. Python has a model of binding references to values, and the Python documentation calls these bindings “variables” in the special case where the reference is a name. So, in that sense, Python has variables. > Python's variables are names bound to values. The ideal, in my view, would be for the Python documentation to never use the term “variable” for this concept, since it leads newcomers predictably to false inferences that mar their understanding of Python. The damage isn't small, since it makes a rather simple and clear concept needlessly difficult to understand, and falsehoods learned about Python's data model need to be carefully rooted out and repaired later down the track. We should, instead, consistently use “reference” and/or “binding” for this concept, since those lead to much more accurate inferences about what is happening. -- \ “People always ask me, ‘Where were you when Kennedy was shot?’ | `\ Well, I don't have an alibi.” —Emo Philips | _o__) | Ben Finney