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


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

Re: Pass variable by reference

Started byNed Batchelder <ned@nedbatchelder.com>
First post2014-05-06 16:31 -0400
Last post2014-05-07 01:14 +0000
Articles 7 on this page of 67 — 16 participants

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

  Re: Pass variable by reference Ned Batchelder <ned@nedbatchelder.com> - 2014-05-06 16:31 -0400
    Re: Pass variable by reference Mark H Harris <harrismh777@gmail.com> - 2014-05-06 16:00 -0500
      Re: Pass variable by reference Ned Batchelder <ned@nedbatchelder.com> - 2014-05-06 17:27 -0400
      Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-07 09:46 +1000
        Re: Pass variable by reference Rustom Mody <rustompmody@gmail.com> - 2014-05-06 19:18 -0700
          Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-07 12:39 +1000
            Re: Pass variable by reference Rustom Mody <rustompmody@gmail.com> - 2014-05-06 19:54 -0700
              Re: Pass variable by reference Steven D'Aprano <steve@pearwood.info> - 2014-05-07 04:59 +0000
        Re: Pass variable by reference Mark H Harris <harrismh777@gmail.com> - 2014-05-07 13:11 -0500
          Re: Pass variable by reference Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 00:22 +0300
            Values and objects [was Re: Pass variable by reference] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 01:08 +0000
              Re: Values and objects [was Re: Pass variable by reference] Mark H Harris <harrismh777@gmail.com> - 2014-05-09 16:56 -0500
                Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-10 01:34 +0300
                  Re: Values and objects Ben Finney <ben@benfinney.id.au> - 2014-05-10 10:24 +1000
                  Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 01:01 +0000
                    Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-09 19:19 -0700
                      Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 12:33 +1000
                        Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-09 20:05 -0700
                          Re: Values and objects Mark H Harris <harrismh777@gmail.com> - 2014-05-09 23:15 -0500
                        Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 06:15 +0000
                          Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 17:21 +1000
                            Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 09:09 +0000
                              Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 19:32 +1000
                              Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 12:10 -0700
                              Re: Values and objects MRAB <python@mrabarnett.plus.com> - 2014-05-10 20:22 +0100
                              Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 12:28 -0700
                              Re: Values and objects Terry Reedy <tjreedy@udel.edu> - 2014-05-10 16:16 -0400
                              Re: Values and objects Terry Reedy <tjreedy@udel.edu> - 2014-05-10 16:24 -0400
                              Re: Values and objects Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-05-10 14:03 -0700
                                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 03:17 +0000
                                  Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 13:30 +1000
                                    Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 05:11 +0000
                                      Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 15:22 +1000
                                        Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-10 22:31 -0700
                                          Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 09:21 +0300
                                            Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-10 23:48 -0700
                                              Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 18:10 +0300
                                            Re: Values and objects Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-05-11 11:26 +0300
                                              Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-11 01:48 -0700
                                                Re: Values and objects Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-05-11 15:22 +0300
                                                  Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 18:46 +0300
                                                    Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 22:56 +0300
                                              Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 12:51 +0000
                                                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-11 07:12 -0700
                                      Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 22:42 -0700
                                        Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 06:40 +0000
                              Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 09:18 +1000
                                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 03:11 +0000
                                  Re: Values and objects Rotwang <sg552@hotmail.co.uk> - 2014-05-11 14:46 +0100
                                    Re: Values and objects Ned Batchelder <ned@nedbatchelder.com> - 2014-05-11 14:40 -0400
                                      Re: Values and objects Rotwang <sg552@hotmail.co.uk> - 2014-05-12 00:06 +0100
                              Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 18:28 -0700
                                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 07:24 +0000
                              Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 11:59 +1000
                                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 07:29 +0000
                              Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 21:46 -0700
                              Re: [Python-Dev] Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 16:08 +1000
                              Re: Values and objects albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-05-17 14:26 +0000
                  Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 11:58 +1000
                    Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-10 10:57 +0300
                      Re: Values and objects Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-05-10 11:06 +0300
                  Re: Values and objects Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-05-10 12:07 -0400
          Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-08 11:31 +1000
            Re: Pass variable by reference Mark H Harris <harrismh777@gmail.com> - 2014-05-09 17:30 -0500
              Abstractions [was Re: Pass variable by reference] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 00:58 +0000
                Re: Abstractions [was Re: Pass variable by reference] Mark H Harris <harrismh777@gmail.com> - 2014-05-09 21:17 -0500
    Re: Pass variable by reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-07 01:14 +0000

Page 4 of 4 — ← Prev page 1 2 3 [4]


#71233 — Re: Values and objects

FromJussi Piitulainen <jpiitula@ling.helsinki.fi>
Date2014-05-10 11:06 +0300
SubjectRe: Values and objects
Message-ID<qot8uqaf46r.fsf@ruuvi.it.helsinki.fi>
In reply to#71231
Marko Rauhamaa writes:

> To me, a variable is a variable is a variable.

That works only in Python.

Elsewhere, the sentence would be interpreted either as "a variable is
True" or as "a variable is False" depending on whether a distinction
without a difference is deemed helpful.

[toc] | [prev] | [next] | [standalone]


#71254 — Re: Values and objects

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-05-10 12:07 -0400
SubjectRe: Values and objects
Message-ID<mailman.9853.1399738054.18130.python-list@python.org>
In reply to#71200
On Sat, 10 May 2014 01:34:58 +0300, Marko Rauhamaa <marko@pacujo.net>
declaimed the following:

>
>Right, Python's variables aren't like variables in C. Rather, Python's
>variables are like CPU registers. They cannot hold typed or structured
>objects and you can't pass references to them.
>
	They aren't like CPU registers either (especially not on the machine I
learned on -- in which the general purpose registers mapped to address 0-15
(longword addresses -- 64 bytes).

	While the opcodes did have a field sized for one register, a
register<>register move used the same opcode as a register<>memory move

	LD,9	MYMEM	;some symbol representing a location in memory
	LD,9	8			;"location" 8, general purpose register as memory

	LDB,9	*8,3		;load a byte, indirectly using the longword
						;whose address is in register 8, using the
						;contents of register 3 as a byte index into
						;the word, into register 9

(yes, the machine used separate LoaD and STore instruction for direction
control... not a generic MOV with two arguments, either of which could be
memory address, and an assembler that had to determine which variant format
was to be generated)



	For CPU registers to act similar to Python you'd have to be alias, at
run-time, register names (and you'd need some other instruction to load a
register value as

	mov	A, B

would result in both A and B becoming the same register -- not one being a
copy of the other.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#71068

FromChris Angelico <rosuav@gmail.com>
Date2014-05-08 11:31 +1000
Message-ID<mailman.9754.1399512719.18130.python-list@python.org>
In reply to#71042
On Thu, May 8, 2014 at 4:11 AM, Mark H Harris <harrismh777@gmail.com> wrote:
> And we must never forget that CPython's underpinnings, uhm C, uses
> variables, C ones...  (never mind)

Be careful of this one. It's utterly irrelevant to your point, and may
be distracting. I could implement Ook in Python; does that mean that
Ook has a socket library? Clearly not.

ChrisA

[toc] | [prev] | [next] | [standalone]


#71198

FromMark H Harris <harrismh777@gmail.com>
Date2014-05-09 17:30 -0500
Message-ID<lkjktj$hr0$1@speranza.aioe.org>
In reply to#71068
On 5/7/14 8:31 PM, Chris Angelico wrote:
> On Thu, May 8, 2014 at 4:11 AM, Mark H Harris <harrismh777@gmail.com> wrote:
>> And we must never forget that CPython's underpinnings, uhm C, uses
>> variables, C ones...  (never mind)
>
> Be careful of this one. It's utterly irrelevant to your point, and may
> be distracting. I could implement Ook in Python; does that mean that
> Ook has a socket library? Clearly not.

     Probably. Although, its turtles all the way down. C is a better way 
to write asm code (more efficient, less lines of code, better 
abstraction, way more readable). wow, use C to build Python.  Python is 
requires way less lines of code than C, better abstraction, more 
efficient, and way more readable. Now, down under the stack of turtles, 
we are still placing values into memory boxes (variables) although we 
are getting there from a very abstract and indirect way; but its turtles 
all the way down from a certain point of view.

     On the other hand, if we are coming at this from the highest level 
(strictly pure Python coding) all we care about is abstracting the real 
world by constructing objects which interact with the rest of the world 
and with themselves. We are no longer interested in modeling memory 
(although that does happen somewhere) --- what we are interested in is 
modeling life and the objects of life. The mechanism of {name: object} 
is so far above the simple name -- value  pair mechanism we used to call 
'variables' (boxes holding native types) that we really need some new 
name for the concept... is a Python 'name' a variable. No. Then what is 
it?  If we call it a variable (what ever we mean by that) someone is 
going to be confused as they try to write Python code. What should it be 
referred to?

     Someone said it is silly to say that Python has no variables. I 
disagree. We need a way to speak about Python variables that highlights 
the distinctions which create for new coders (and some old ones too) the 
misunderstandings and surprises which spark a debate like this one. As 
someone else pointed out its a both|and.  I suppose I agree. OTOH:

A = 7

Seven is not a C integer native type, and A is not a static int 
variable.  7 is an object, and the name A is bound to it.  What shall we 
call  A  ?

object nomenclature :   A is objname,  objhandle,  OBH. or just handle.

I think we need to stop calling it a variable.


marcus

[toc] | [prev] | [next] | [standalone]


#71207 — Abstractions [was Re: Pass variable by reference]

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-05-10 00:58 +0000
SubjectAbstractions [was Re: Pass variable by reference]
Message-ID<536d79d1$0$29980$c3e8da3$5496439d@news.astraweb.com>
In reply to#71198
On Fri, 09 May 2014 17:30:10 -0500, Mark H Harris wrote:

> On 5/7/14 8:31 PM, Chris Angelico wrote:
>> On Thu, May 8, 2014 at 4:11 AM, Mark H Harris <harrismh777@gmail.com>
>> wrote:
>>> And we must never forget that CPython's underpinnings, uhm C, uses
>>> variables, C ones...  (never mind)
>>
>> Be careful of this one. It's utterly irrelevant to your point, and may
>> be distracting. I could implement Ook in Python; does that mean that
>> Ook has a socket library? Clearly not.
> 
>      Probably. Although, its turtles all the way down. C is a better way
> to write asm code (more efficient, less lines of code, better
> abstraction, way more readable). wow, use C to build Python.  Python is
> requires way less lines of code than C, better abstraction, more
> efficient, and way more readable. Now, down under the stack of turtles,
> we are still placing values into memory boxes (variables) although we
> are getting there from a very abstract and indirect way; but its turtles
> all the way down from a certain point of view.

I think you have missed the point that "turtles all the way down" means 
an *infinite* chain of abstractions, not a finite one. But when running 
code, eventually you reach hardware, and the chain of abstractions ends. 
No more turtles.

Suppose I run some code in a BASIC interpreter written in Prolog, which I 
run in an emulator written in Python, running on PyPy. Then we have the 
following levels of explanation of what's going on, from the most high 
level to the lowest level:

    BASIC
    Prolog
    Python
    RPython
    C
    Machine code
    Micro code

and we reach the actual hardware layer and the abstractions are over.

(If you want to nit-pic about whether micro code is an abstraction, 
that's fine, you can add a layer or two if you wish. But we're not far 
from *actual electric currents in an actual physical device*, at which 
point we're now talking about a concrete, physical description of the 
process, not an abstraction. There really is a bottom-most turtle that 
holds up all the rest.)



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/

[toc] | [prev] | [next] | [standalone]


#71213 — Re: Abstractions [was Re: Pass variable by reference]

FromMark H Harris <harrismh777@gmail.com>
Date2014-05-09 21:17 -0500
SubjectRe: Abstractions [was Re: Pass variable by reference]
Message-ID<lkk288$fm1$1@speranza.aioe.org>
In reply to#71207
On 5/9/14 7:58 PM, Steven D'Aprano wrote:
> {snip} at which
> point we're now talking about a concrete, physical description of the
> process, not an abstraction. There really is a bottom-most turtle that
> holds up all the rest.)
>

hi Steven, heh... yup, there really is a bottom-most turtle (and who 
created him?)

Intel  (often copied, never exceeded)

:))



[toc] | [prev] | [next] | [standalone]


#70999

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-05-07 01:14 +0000
Message-ID<536988da$0$29965$c3e8da3$5496439d@news.astraweb.com>
In reply to#70985
On Tue, 06 May 2014 16:31:35 -0400, Ned Batchelder wrote:

> On 5/6/14 12:42 AM, Gary Herron wrote:
>> This gets confusing, but in fact the most accurate answer is that
>> Python does not have "variables", so there is no such thing as passing
>> "variables" by reference or any other method.  Python *does* have names
>> bound to values, but that's a very different thing. If necessary, you
>> may consider that the *values* are passed by reference.
> 
> This meme bugs me so much.  Python has variables.  They work differently
> than variables in C.  In fact, they work by having names bound to
> values.
> 
> If you want to insist that Python has no variables, you will have to
> also say that neither do Javascript, Ruby, Java, PHP, etc.  And if
> Javascript has no variables, what does the var keyword mean?

It's Javascript, which is barely one step up from PHP regarding 
consistency. It could mean "constant" for all I know :-)




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

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


csiph-web