Re: Abstractions [was Re: Pass variable by reference]

2014-05-09 Thread Mark H Harris
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 c

Abstractions [was Re: Pass variable by reference]

2014-05-09 Thread Steven D'Aprano
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 >> wrote: >>> And we must never forget that CPython's underpinnings, uhm C, uses >>> variables, C ones... (never mind) >> >> Be careful of this one

Re: Pass variable by reference

2014-05-09 Thread Mark H Harris
On 5/7/14 8:31 PM, Chris Angelico wrote: On Thu, May 8, 2014 at 4:11 AM, Mark H Harris 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 im

Re: Values and objects [was Re: Pass variable by reference]

2014-05-09 Thread Mark H Harris
On 5/7/14 8:08 PM, Steven D'Aprano wrote: In Python, all values *are* objects. It isn't a matter of choosing one or the other. The value 1 is an object, not a native (low-level, unboxed) 32 or 64 bit int. Unlike C# or Java, there is no direct language facility to box native values into objects o

Value vs Identity (was Re: Pass variable by reference)

2014-05-07 Thread Chris Angelico
On Thu, May 8, 2014 at 7:22 AM, Marko Rauhamaa wrote: > Mark H Harris : > >> A == B >> True >> >> A is B >> False >> >> [...] >> >> This is just one of a dozen 'different' kinds of examples. And the >> answer is the same, Python does not have variables, Python has names >> bound to objects. > > Th

Re: Pass variable by reference

2014-05-07 Thread Chris Angelico
On Thu, May 8, 2014 at 4:11 AM, Mark H Harris 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 tha

Values and objects [was Re: Pass variable by reference]

2014-05-07 Thread Steven D'Aprano
On Thu, 08 May 2014 00:22:55 +0300, Marko Rauhamaa wrote: > But hey, we can open another thread for whether Python has values or > objects! In Python, all values *are* objects. It isn't a matter of choosing one or the other. The value 1 is an object, not a native (low-level, unboxed) 32 or 64 b

Re: Pass variable by reference

2014-05-07 Thread Marko Rauhamaa
Mark H Harris : > A == B > True > > A is B > False > > [...] > > This is just one of a dozen 'different' kinds of examples. And the > answer is the same, Python does not have variables, Python has names > bound to objects. That is a different topic and isn't related to variables at all. Instead,

Re: Pass variable by reference

2014-05-07 Thread Mark H Harris
On 5/6/14 6:46 PM, Chris Angelico wrote: Is there really a fundamental difference between languages in which that is equally valid syntax and does exactly the same thing? No. And from that standpoint, python has variables. I know, because I thought about python's 'variables' as variables for

Re: Pass variable by reference

2014-05-06 Thread Steven D'Aprano
On Tue, 06 May 2014 19:54:28 -0700, Rustom Mody wrote: > The number of possible concepts is infinite > > The number of words is finite (even assuming unicode!!) Not true. If you allow longer and longer words, with no upper limit, the number of words is also infinite. If you allow compound word

Re: Pass variable by reference

2014-05-06 Thread Rustom Mody
On Wednesday, May 7, 2014 8:09:34 AM UTC+5:30, Chris Angelico wrote: > On Wed, May 7, 2014 at 12:18 PM, Rustom Mody wrote: > > Wrong conclusion! > > These 3 lines look the same and amount to much the same in python and C. > > But as the example widens to something beyond 3 lines, the difference > >

Re: Pass variable by reference

2014-05-06 Thread Chris Angelico
On Wed, May 7, 2014 at 12:18 PM, Rustom Mody wrote: > Wrong conclusion! > > These 3 lines look the same and amount to much the same in python and C. > > But as the example widens to something beyond 3 lines, the difference > will become more and more significant Python, C, REXX, BASIC, and pretty

Re: Pass variable by reference

2014-05-06 Thread Rustom Mody
On Wednesday, May 7, 2014 5:16:16 AM UTC+5:30, Chris Angelico wrote: > On Wed, May 7, 2014 at 7:00 AM, Mark H Harris wrote: > Is this code mutating or rebinding? > x = 1.1 > y = 2.2 > x = x + y Heh! Neat example! > What language did I write that in? Is there really a fundamental > difference

Re: Pass variable by reference

2014-05-06 Thread Steven D'Aprano
On Tue, 06 May 2014 15:16:54 -0400, Terry Reedy wrote: > On 5/5/2014 8:39 PM, Satish Muthali wrote: >> Hello experts, >> >> I have a burning question on how to pass variable by reference in >> Python. > > Python passes objects to functions. CPython implements this by passing > object pointers. In

Re: Pass variable by reference

2014-05-06 Thread Steven D'Aprano
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

Re: Pass variable by reference

2014-05-06 Thread Chris Angelico
On Wed, May 7, 2014 at 7:00 AM, Mark H Harris wrote: > What does the word "variable" mean. Think BASIC variables. You can set them, > you can reset them, you can delete them, you can change them. ... because > they are variable. > > Python has names bound to objects... some of which you may not c

Re: Pass variable by reference

2014-05-06 Thread Ned Batchelder
On 5/6/14 5:00 PM, Mark H Harris wrote: On 5/6/14 3:31 PM, 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

Re: Pass variable by reference

2014-05-06 Thread Mark H Harris
On 5/6/14 3:31 PM, 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 t

Re: Pass variable by reference

2014-05-06 Thread Michael Torrie
On 05/05/2014 06:39 PM, Satish Muthali wrote: > I want to nuke /var/lib/postgresql/9.3.4/main/data , however > programatically I want it to be as: /var/lib/postgresql/ pgversion>/main/data > > Any help is appreciated. Not sure really. But if you want to pass a some data around that can be manip

Re: Pass variable by reference

2014-05-06 Thread Ned Batchelder
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 thin

Re: Pass variable by reference

2014-05-06 Thread Terry Reedy
On 5/5/2014 8:39 PM, Satish Muthali wrote: Hello experts, I have a burning question on how to pass variable by reference in Python. Python passes objects to functions. CPython implements this by passing object pointers. In one sense, your request is impossible. In another, it already happens

Re: Pass variable by reference

2014-05-06 Thread Chris Angelico
On Tue, May 6, 2014 at 8:38 PM, Marko Rauhamaa wrote: > Chris Angelico : > >>> characters, words, lines = stats.read() >> >> That's not really pass-by-reference, though. What you're doing is >> output parameters, which are usually implemented in C with pointers, >> but in Python with a return

Re: Pass variable by reference

2014-05-06 Thread Marko Rauhamaa
Chris Angelico : >> characters, words, lines = stats.read() > > That's not really pass-by-reference, though. What you're doing is > output parameters, which are usually implemented in C with pointers, > but in Python with a return tuple. Correct, but it is worth questioning the question itsel

Re: Pass variable by reference

2014-05-06 Thread Chris Angelico
On Tue, May 6, 2014 at 7:11 PM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Mon, 05 May 2014 17:39:44 -0700, Satish Muthali wrote: >>> I have a burning question on how to pass variable by reference in >>> Python. I understand that the data type has to be mutable. >> >> [...] >> >> To get an

Re: Pass variable by reference

2014-05-06 Thread Marko Rauhamaa
Steven D'Aprano : > On Mon, 05 May 2014 17:39:44 -0700, Satish Muthali wrote: >> I have a burning question on how to pass variable by reference in >> Python. I understand that the data type has to be mutable. > > [...] > > To get an effect *similar* to pass-by-reference, you can wrap your > varia

Re: Pass variable by reference

2014-05-06 Thread Steven D'Aprano
On Mon, 05 May 2014 17:39:44 -0700, Satish Muthali wrote: > Hello experts, > > I have a burning question on how to pass variable by reference in > Python. I understand that the data type has to be mutable. Python provides neither pass-by-reference nor pass-by-value argument passing. Please rea

Re: Pass variable by reference

2014-05-05 Thread Gary Herron
On 05/05/2014 05:39 PM, Satish Muthali wrote: Hello experts, I have a burning question on how to pass variable by reference in Python. I understand that the data type has to be mutable. This gets confusing, but in fact the most accurate answer is that Python does not have "variables", so th

Re: Pass variable by reference

2014-05-05 Thread Rustom Mody
On Tuesday, May 6, 2014 6:09:44 AM UTC+5:30, Satish Muthali wrote: > Hello experts, > I have a burning question on how to pass variable by reference in Python. Technically correct answer: You cant. But see below. > I understand that the data type has to be mutable. I dont know that mutability h