Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70996

Re: The “does Python have variables?” debate (was: Pass variable by reference)

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'parameters': 0.04; 'subject:Python': 0.06; 'assignment': 0.07; 'javascript,': 0.07; 'rename': 0.07; 'variables': 0.07; 'meaningful': 0.09; 'php,': 0.09; 'ruby,': 0.09; 'uses.': 0.09; 'variables.': 0.09; '\xe2\x80\x94': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'mostly': 0.14; 'assigned,': 0.16; 'binding.': 0.16; 'bindings.': 0.16; 'declared': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:variable': 0.16; 'variables,': 0.16; 'exception': 0.16; 'java,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; "python's": 0.19; 'cc:addr:python.org': 0.22; 'basis,': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'see,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'keywords,': 0.31; 'there.': 0.32; 'languages': 0.32; 'actual': 0.34; 'comment': 0.34; 'subject: (': 0.35; "can't": 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'are,': 0.36; 'object,': 0.36; 'useful': 0.36; 'expected': 0.38; 'ben': 0.38; 'others.': 0.38; 'previous': 0.38; 'anything': 0.39; 'enough': 0.39; 'name': 0.63; 'term': 0.63; 'subject:The': 0.64; 'different': 0.65; 'skip:\xe2 10': 0.65; 'containing': 0.69; 'subjectcharset:utf-8': 0.72; '8bit%:43': 0.74; 'subject:have': 0.80; "'local'": 0.84; '(always': 0.84; 'around,': 0.84; 'confusing': 0.84; 'local,': 0.84; 'to:none': 0.92; 'imagine': 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:content-transfer-encoding; bh=oYwuxv/XSdFkhgaRw+seqFIXoBYJILVQ/X65bkz4kp4=; b=uIuSH9qfBhGCBY72WZhWgqR1mY7e3QQCC/wMOcPX28AzgUNAg+MY5ZU4KzxabDc1RG 9POpvbG9MOLWb5TXyMk1HscD/TTEnMdsnddwH9hFrerFHoKgC+TXGO9n+u3JRDk3jtgX Pw2rf7Mi9pkKmamtue+kkcZPmgTS0ADZUqIozsdmvzbVXgQNA282nmBUJ99/WDL2vk0/ AgFB6D4iL5/6WTaJ/YOouaatGohw5ecF3Ip3kKWUsyiHf54XKuuDWE+QrKrhjHRIcI/f tABwst2oNLZcyKu1cTMrKLA1c0C5W/kE//hTxq1lY7JegqyQ2D2DiLwXOUnoteI+m4zT YtCw==
MIME-Version 1.0
X-Received by 10.58.116.1 with SMTP id js1mr4153929veb.29.1399421461137; Tue, 06 May 2014 17:11:01 -0700 (PDT)
In-Reply-To <85zjiuea37.fsf_-_@benfinney.id.au>
References <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> <5368681D.8070602@islandtraining.com> <lkbgr7$e6o$1@ger.gmane.org> <85zjiuea37.fsf_-_@benfinney.id.au>
Date Wed, 7 May 2014 10:11:01 +1000
Subject Re: The “does Python have variables?” debate (was: Pass variable by reference)
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9719.1399421463.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1399421463 news.xs4all.nl 2833 [2001:888:2000:d::a6]:44993
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70996

Show key headers only | View raw


On Wed, May 7, 2014 at 9:55 AM, Ben Finney <ben@benfinney.id.au> wrote:
>> If you want to insist that Python has no variables, you will have to
>> also say that neither do Javascript, Ruby, Java, PHP, etc.
>
> I don't know enough Ruby to comment there. For Java, Javascript, PHP,
> they *do* have variables that work pretty much as expected by these
> newcomers: the variables are declared and exist before a value is
> assigned, they have the “box containing a value” conceptual model (as
> contrasted with Python's “value with sticky-notes attached” model), the
> “how do I pass by reference or by value?” question is meaningful — all
> of these are significantly different in Python, so the term “variable”
> is useful in those other languages but mostly just a confusing obstacle
> in learning Python.

JS "variables" are just name bindings. Imagine this change to the
Python parser: abolish the 'global' and 'nonlocal' keywords, and
instead declare 'local' anything that you want to be function-local.
(Always function-local. No actual change to Python byte-code.) Instead
of looking for assignment and declaring local on that basis, you look
for a 'local x' declaration. (Function parameters are, of course,
implicitly local, as in current model.) Now just rename "local" to
"var" and you have the JS scope model.

You can't pass by reference in JS; you pass objects around, exactly as
with Python. (With an exception with functions, where "x.y()" is
different from "f=x.y; f()", which strikes me as brain-dead design.)
You can have multiple names bound to the same object, and a mutation
in one is seen in the others. Rebinding a name disconnects it from the
previous binding. From what I can see, it's the same object model as
Python uses. And people are happy to talk about JS variables.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: The “does Python have variables?” debate (was: Pass variable by reference) Chris Angelico <rosuav@gmail.com> - 2014-05-07 10:11 +1000

csiph-web