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


Groups > comp.lang.python > #70992 > unrolled thread

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

Started byBen Finney <ben@benfinney.id.au>
First post2014-05-07 09:55 +1000
Last post2014-05-07 09:55 +1000
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.


Contents

  The “does Python have variables?” debate (was: Pass variable by reference) Ben Finney <ben@benfinney.id.au> - 2014-05-07 09:55 +1000

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

FromBen Finney <ben@benfinney.id.au>
Date2014-05-07 09:55 +1000
SubjectThe “does Python have variables?” debate (was: Pass variable by reference)
Message-ID<mailman.9715.1399420540.18130.python-list@python.org>
Ned Batchelder <ned@nedbatchelder.com> writes:

> This meme bugs me so much. Python has variables. They work differently
> than variables in C.

Which is why it's useful to intervene right at the start when someone
comes in with assumptions about “variables”; it's better that they
discard that baggage and learn about reference binding, instead.

> In fact, they work by having names bound to values.

My position is that this concept is sufficiently different to what most
newcomers to Python mean by “variable” (those who have the term at all;
and for those who don't, no need to introduce potentially-confusing
terms) that it's better to avoid that term entirely and immediately use
more-accurate terminology.

> 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.

> And if Javascript has no variables, what does the var keyword mean?

Exactly; JavaScript *does* have variables, in the ways Python does not.

-- 
 \        “If you have the facts on your side, pound the facts. If you |
  `\     have the law on your side, pound the law. If you have neither |
_o__)                       on your side, pound the table.” —anonymous |
Ben Finney

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web