Re: The � debate

2014-05-10 Thread Gregory Ewing

Steven D'Aprano wrote:

some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

I'm pretty sure that it isn't common to call the LHS of that assignment a 
variable.


A better way of putting it might be something in the data
model that can be assigned to.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Chris Angelico
On Sat, May 10, 2014 at 3:58 PM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 Steven D'Aprano wrote:

 some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

 I'm pretty sure that it isn't common to call the LHS of that assignment a
 variable.


 A better way of putting it might be something in the data
 model that can be assigned to.

https://en.wikipedia.org/wiki/Assignment_(computer_science)

Go ahead, start an edit war at that page over its use of variable.
:) Right there it talks about copying values into variables. So if
Python has no variables, then either that article is inappropriate, or
Python has no assignment either.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 17:10:29 +1000, Chris Angelico wrote:

 On Sat, May 10, 2014 at 3:58 PM, Gregory Ewing
 greg.ew...@canterbury.ac.nz wrote:
 Steven D'Aprano wrote:

 some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

 I'm pretty sure that it isn't common to call the LHS of that
 assignment a variable.


 A better way of putting it might be something in the data model that
 can be assigned to.
 
 https://en.wikipedia.org/wiki/Assignment_(computer_science)
 
 Go ahead, start an edit war at that page over its use of variable. :)
 Right there it talks about copying values into variables. So if Python
 has no variables, then either that article is inappropriate, or Python
 has no assignment either.

Python assignment doesn't copy values.




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Chris Angelico
On Sat, May 10, 2014 at 5:48 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 https://en.wikipedia.org/wiki/Assignment_(computer_science)

 Go ahead, start an edit war at that page over its use of variable. :)
 Right there it talks about copying values into variables. So if Python
 has no variables, then either that article is inappropriate, or Python
 has no assignment either.

 Python assignment doesn't copy values.

So either the article is wrong, or Python doesn't have assignment. Which is it?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Sat, May 10, 2014 at 3:58 PM, Gregory Ewing
 greg.ew...@canterbury.ac.nz wrote:
 Steven D'Aprano wrote:

 some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

 I'm pretty sure that it isn't common to call the LHS of that assignment a
 variable.

 [...]
 https://en.wikipedia.org/wiki/Assignment_(computer_science)

 [...]

 So if Python has no variables, then either that article is
 inappropriate, or Python has no assignment either.

Many complaints against Python's variables are really comments on
Python's object model.

Steven's example points out a different angle: many complaints against
Python's variables are really comments on Python's assignment statement
(including argument passing).

In Python,

   x   is a variable, a memory slot that can be assigned to,
   a[3]is a list element, a memory slot that can be assigned to,
   d['y']  is a dict entry, a memory slot that can be assigned to,
   o.f is a field, a memory slot that can be assigned to

Now, Python (together with a host of other programming languages) lacks
a way to pass memory slots by reference (although the list/dict+key
comes close). However, the fact that you can't get a reference to a
variable/list element/dict entry/field doesn't mean Python doesn't have
variables/list elements/dict entries/fields.


Marko

PS I have mentioned before that Python 3 *does* allow you to pass a
reference to any LHS by constructing an ad-hoc accessor object:

x, y = 2, 3
class X:
def get(self): return x
def set(self, v): nonlocal x; x = v
class Y:
def get(self): return y
def set(self, v): nonlocal y; y = v
swap(X(), Y())
print(x, y)
= 3, 2

Such ad-hoc accessor classes are required for nonglobal variables only.
Generic accessor classes can be written for global variables, list
elements, dict entries and fields.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Sat, May 10, 2014 at 5:48 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 https://en.wikipedia.org/wiki/Assignment_(computer_science)

 Go ahead, start an edit war at that page over its use of variable. :)
 Right there it talks about copying values into variables. So if Python
 has no variables, then either that article is inappropriate, or Python
 has no assignment either.

 Python assignment doesn't copy values.

 So either the article is wrong, or Python doesn't have assignment.
 Which is it?

You can understand copying more liberally:

   assignment   -- 0-level copy
   shallow copy -- 1-level copy
   deep copy-- infinite-level copy

Real programs occasionally need 2-level or n-level copies.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Rustom Mody
On Saturday, May 10, 2014 1:18:27 PM UTC+5:30, Steven D'Aprano wrote:
 Python assignment doesn't copy values.

Maybe our values differ wink?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Steven D'Aprano
On Sat, 10 May 2014 11:18:59 +0300, Marko Rauhamaa wrote:

 In Python,
 
x   is a variable, a memory slot that can be assigned to,


If your intention was to prove Ben Finney right, then you've done a 
masterful job of it. Python variables ARE NOT MEMORY SLOTS.

(Not even local variables, since that's an implementation detail which 
the language takes pains to hide from the caller. The abstraction leaks a 
bit, but not much.)



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-10 Thread Ethan Furman

On 05/10/2014 02:05 AM, Rustom Mody wrote:

On Saturday, May 10, 2014 1:18:27 PM UTC+5:30, Steven D'Aprano wrote:


Python assignment doesn't copy values.


Maybe our values differ?


Obviously they do.  Yours are irrelevant for Python.  They could be, and probably are, useful when comparing and 
contrasting Python with other languages, or maybe when discussing a particular implementation of Python -- but when 
discussing the *language* of Python, your definition of value doesn't exist.


When learning a foreign human language most folks start at, and some stay at, the think in native language, translate 
on the fly mode.  And it probably works well enough to get by.  But that is not fluency.  Fluency is understanding the 
meaning behind the words, behind the sounds, and eventually being able to *think* in that other language.


If that is not your goal, fine;  please stop muddying other's understanding of 
how Python the language works.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 13:10:41 +1200, Gregory Ewing wrote:

 Steven D'Aprano wrote:
 Today we routinely call horseless carriages cars, and nobody would
 blink if I pointed at a Prius or a Ford Explorer and said that's not a
 carriage, it's a car except to wonder why on earth I thought something
 so obvious needed to be said.
 
 That's only because the term car *is* well established. The situation
 with the word variable is more like if you pointed at a Prius and said
 That's not a car, it's an electric vehicle. Most people would wonder
 why you refused to categorise it as a type of car.

And of there was an ongoing problem with people getting seriously 
confused by the differences between electric vehicles and internal 
combustion engine cars -- say, a steady stream of Prius owners filling 
the windshield washer reservoir with petrol (gasoline for Americans), or 
car mechanics accidentally blowing the batteries up -- then there might 
be a good reason to use a different name. In the absence of such 
confusion, why should we care?

I don't object to Python using print to mean display on the screen 
instead of make paper come out of the printer, because with the 
exception of the most naive beginners, there is no confusion caused by 
using that term. Nor am I terrible upset that static method means 
something very different in Java to Python, because that represents a 
fairly trivial misunderstanding about a single function rather than a 
fundamental misunderstanding about language semantics.


 If you look at the way the word variable is used across a variety of
 language communities, the common meaning is more or less something that
 can appear on the left hand side of an assignment statement.

I really don't think so.

some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42

I'm pretty sure that it isn't common to call the LHS of that assignment a 
variable.


 Nobody seems to complain about using the term assigment in relation to
 Python, despite it meaning something a bit different from what it means
 in some other languages, so I don't see anything wrong with using the
 term variable with the above definition.

What differences in assignment are you referring to?

In any case, the issue is whether or not the misunderstanding leads to 
confusion or not. 



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-09 Thread Mark H Harris

On 5/9/14 8:34 PM, Steven D'Aprano wrote:

Nobody seems to complain about using the term assigment in relation to
Python, despite it meaning something a bit different from what it means
in some other languages, so I don't see anything wrong with using the
term variable with the above definition.


What differences in assignment are you referring to?

In any case, the issue is whether or not the misunderstanding leads to
confusion or not.

   That's really the question --- regarding the issue of 'variable' and 
assignment.


   The term 'variable' (assignment) typically means: the LHS (name) of 
an assignment where the coder is placing some 'type' (RHS) into a chunk 
of memory statically defined, or dynamically malloc'd.


   With Python the assignment term 'variable' means: the LHS (name) is 
now associated with (bound to) an object (RHS), regardless whether the 
object already exists or whether the object is being constructed, nor 
what kind or type the object may be. The coder is not concerned with the 
memory model, nor address, nor reference.


   So for Python variable names are object handles.

   I've been reading through the python docs today (the FAQ mostly) and 
noting that python has variables BIG TIME as far as the docs go.



marcus



--
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-08 Thread Gregory Ewing

Steven D'Aprano wrote:
Today we routinely call horseless carriages 
cars, and nobody would blink if I pointed at a Prius or a Ford Explorer 
and said that's not a carriage, it's a car except to wonder why on 
earth I thought something so obvious needed to be said.


That's only because the term car *is* well established.
The situation with the word variable is more like if you
pointed at a Prius and said That's not a car, it's an
electric vehicle. Most people would wonder why you refused
to categorise it as a type of car.

If you look at the way the word variable is used across
a variety of language communities, the common meaning is
more or less something that can appear on the left hand
side of an assignment statement.

Nobody seems to complain about using the term assigment
in relation to Python, despite it meaning something a bit
different from what it means in some other languages, so I
don't see anything wrong with using the term variable
with the above definition.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: The � debate

2014-05-08 Thread Ben Finney
Gregory Ewing greg.ew...@canterbury.ac.nz writes:

 If you look at the way the word variable is used across a variety of
 language communities, the common meaning is more or less something
 that can appear on the left hand side of an assignment statement.

The clear experience from years in this and other Python forums is that
newcomers frequently draw from the term “variable” additional, specific,
inferences that are *false* for Python.

My position is that the responsibility for avoiding terms that are
likely to encourage newcomers to draw false inferences falls to us, as
existing knowledgeable community members teaching newcomers.

 Nobody seems to complain about using the term assigment in relation
 to Python, despite it meaning something a bit different from what it
 means in some other languages, so I don't see anything wrong with
 using the term variable with the above definition.

To the extent that the term encourages or enables a mental model that is
significantly likely to lead to false inferences, the term is harmful
for a newcomer's learning.

That extent varies with each newcomer, of course; I'm pointing out that
the proportion of newcomers arriving here with a mental model of
“variable” which will produce false inferences is high enough that the
term is best replaced by terms that imply more-accurate mental models.

-- 
 \   “A computer once beat me at chess, but it was no match for me |
  `\ at kick boxing.” —Emo Philips |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list