Re: [Tutor] When is = a copy and when is it an alias

2014-01-29 Thread spir
On 01/29/2014 02:34 AM, Denis Heidtmann wrote: Glad to hear it. That is what I was hoping, but I did not want to question a helpful person. (you could & should, we need helpful feedback too, to improve our skills; i mean, as long as it's honest indeed) d

Re: [Tutor] When is = a copy and when is it an alias

2014-01-29 Thread Denis Heidtmann
On Tue, Jan 28, 2014 at 5:19 PM, Alan Gauld wrote: > On 28/01/14 19:00, Denis Heidtmann wrote: > >> On Tue, Jan 28, 2014 at 12:28 AM, spir > > > This is getting confusing with two times Denis! > > > wrote: >> >> a = [1,[2,3]] >> > > I think the above l

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread spir
On 01/29/2014 02:10 AM, Dave Angel wrote: Denis Heidtmann Wrote in message: What is going on? I am more confused than I was a week ago. Simple. spir has copy/paste editing errors. Oops! sorry d ___ Tutor maillist - Tutor@python.org To u

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread Alan Gauld
On 28/01/14 19:00, Denis Heidtmann wrote: On Tue, Jan 28, 2014 at 12:28 AM, spir This is getting confusing with two times Denis! > wrote: a = [1,[2,3]] I think the above line is a mistake. If Denis(spir) had missed this out his code would work a

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread Dave Angel
Denis Heidtmann Wrote in message: > > What is going on?  I am more confused than I was a week ago. Simple. spir has copy/paste editing errors. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread Danny Yoo
Hi Denis, Ok, stop for a moment. Visit:http://pythontutor.com/visualize.html Specifically, here's your program: http://pythontutor.com/visualize.html#code=a%3D%5B1,%5B1,2%5D%5D%0Ab%3Da%0Aa%3D%5B1,%5B2,3%5D%5D%0Aa%5B0%5D%3D0%0Aa%5B1%5D%3D%5B0,0%5D&mode=display&cumulative=false&heapPrimitive

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread Denis Heidtmann
On Tue, Jan 28, 2014 at 12:28 AM, spir wrote: > > > a = [1, [1,2]] b = a b >>> [1, [1, 2]] > >> b is a >>> True > > a's and b's values are a single, unique object... as long as I only > modified them (the values) partly: > > a = [1,[2,3]] a[0] = 0 b >>> [0, [

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread spir
On 01/27/2014 06:04 PM, Denis Heidtmann wrote: Apparently a[0]=b[0] does not qualify as "symbolic assignment" in this case. a[0] is not a reference to b[0]. I think I see the essential distinction. Experience will complete the picture for me. "symolic assignment" is my term, so whatever I mea

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread eryksun
On Mon, Jan 27, 2014 at 9:07 AM, Mark Lawrence wrote: > On 27/01/2014 09:53, spir wrote: >> >> Note: your example is strongly obscured by using weird and rare features >> that don't bring any helpful point to the actual problematic concepts >> you apparently want to deal with. >> > > Nothing weird

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread eryksun
On Mon, Jan 27, 2014 at 2:01 PM, Danny Yoo wrote: > And variable binding itself can even have a slightly > different meaning, depending on whether the surrounding context is a > function definition or not, establishing a local or global variable > binding. Whew! Name binding is local unless you

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread Danny Yoo
> Apparently a[0]=b[0] does not qualify as "symbolic assignment" in this case. > a[0] is not a reference to b[0]. I think I see the essential distinction. > Experience will complete the picture for me. Yes. The distinction is something that is blurred by Python's syntax. The "=" is a conceptual

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread Denis Heidtmann
Thanks for the responses. The distinction between replacement and modification seems to capture the essential aspect and helps to clarify the issue for me. spir: Quite the opposite, in python "symbolic assignment" (where the right side also is a symbol) never copies, in fact never creates a new v

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread Mark Lawrence
On 27/01/2014 09:53, spir wrote: On 01/27/2014 07:16 AM, Denis Heidtmann wrote: Running python 2.7 in linux Below are two extremes. Can I get some guidance on this? Thanks, -Denis H a=zeros((2,3),dtype=int) b=a a[:,0]=[1,2] a array([[1, 0, 0], [2, 0, 0]]) b array([[1, 0, 0],

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread Peter Otten
Denis Heidtmann wrote: > Running python 2.7 in linux > > Below are two extremes. Can I get some guidance on this? a=zeros((2,3),dtype=int) b=a a[:,0]=[1,2] a > array([[1, 0, 0], >[2, 0, 0]]) b > array([[1, 0, 0], >[2, 0, 0]]) a=2 a > 2 b >

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread spir
On 01/27/2014 07:16 AM, Denis Heidtmann wrote: Running python 2.7 in linux Below are two extremes. Can I get some guidance on this? Thanks, -Denis H a=zeros((2,3),dtype=int) b=a a[:,0]=[1,2] a array([[1, 0, 0], [2, 0, 0]]) b array([[1, 0, 0], [2, 0, 0]]) a=2 a 2 b arra

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread Steven D'Aprano
Hi Denis, and welcome! On Sun, Jan 26, 2014 at 10:16:25PM -0800, Denis Heidtmann wrote: > Running python 2.7 in linux > > Below are two extremes. Can I get some guidance on this? In Python, = is ALWAYS an alias, never a copy, unless you explicitly do something to make a copy. For example, wit

[Tutor] When is = a copy and when is it an alias

2014-01-27 Thread Denis Heidtmann
Running python 2.7 in linux Below are two extremes. Can I get some guidance on this? Thanks, -Denis H >>> a=zeros((2,3),dtype=int) >>> b=a >>> a[:,0]=[1,2] >>> a array([[1, 0, 0], [2, 0, 0]]) >>> b array([[1, 0, 0], [2, 0, 0]]) >>> a=2 >>> a 2 >>> b array([[1, 0, 0], [2, 0,