Re: [Tutor] lists, name semantics

2015-04-19 Thread Alan Gauld
On 20/04/15 00:29, Laura Creighton wrote: So in this case, the binding value is an integer, not an address. Utterly wrong. The binding value has to be an address. I think it depends on how you define 'binding' value. In Python binding is the connection between a name and an object. So in a

Re: [Tutor] lists, name semantics

2015-04-19 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 19:19:27 -0400, Dave Angel writes: >Good answer. The java jvm garbage collector is free to move blocks >around to defrag the free space. Correct. >FWIW, I'm told the ID value used is a simple integer, that indexes a >list containing the actual addresses. Also

Re: [Tutor] lists, name semantics

2015-04-19 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 17:23:13 -0500, boB Stepp writes: >The last sentence in this paragraph has me intrigued. Why would an >object, once it has been created, be moved? What practical benefit >does doing this give? > boB If you have more than enough memory in your system, you never do t

Re: [Tutor] lists, name semantics

2015-04-19 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 17:23:13 -0500, boB Stepp writes: >On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: >> abstract, and the details are unimportant to the user. For example, the >> jython system does not use addresses at all. And an object gets moved >> around from time to time w

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 06:28 PM, Joel Goldstick wrote: On Sun, Apr 19, 2015 at 6:23 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: On 04/19/2015 03:08 PM, boB Stepp wrote: Or is the real point that we are adding an abstraction layer so we don't even have to think about wh

Re: [Tutor] lists, name semantics

2015-04-19 Thread Joel Goldstick
On Sun, Apr 19, 2015 at 6:23 PM, boB Stepp wrote: > On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: >> On 04/19/2015 03:08 PM, boB Stepp wrote: >>> > >>> Or is the real point that we are adding an abstraction >>> layer so we don't even have to think about where objects are >>> physically store

Re: [Tutor] lists, name semantics

2015-04-19 Thread boB Stepp
On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: > On 04/19/2015 03:08 PM, boB Stepp wrote: >> >> Or is the real point that we are adding an abstraction >> layer so we don't even have to think about where objects are >> physically stored in RAM? > > > Somebody keeps track, but the address is no

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 03:08 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 6:47 AM, Dave Angel wrote: On 04/19/2015 12:07 AM, boB Stepp wrote: [...] I hope this is helpful, and, if there are any misstepps, that when they are revealed both of our understandings will be enhanced! Some of your knowle

Re: [Tutor] lists, name semantics

2015-04-19 Thread boB Stepp
On Sun, Apr 19, 2015 at 6:47 AM, Dave Angel wrote: > On 04/19/2015 12:07 AM, boB Stepp wrote: [...] >> I hope this is helpful, and, if there are any misstepps, that when >> they are revealed both of our understandings will be enhanced! >> > > Some of your knowledge of other languages is leaking

Re: [Tutor] lists, name semantics

2015-04-19 Thread boB Stepp
On Sun, Apr 19, 2015 at 12:24 AM, Cameron Simpson wrote: > On 19Apr2015 15:09, Cameron Simpson wrote: >> >> On 18Apr2015 23:26, boB Stepp wrote: >>> >>> On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: [...] >>> "Two problems often exist with deep copy operations that don’t exist >>>

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 12:07 AM, boB Stepp wrote: . Before Peter changed one of these changeable objects, he had: a = [1, ["x", "y"], 3] b = a[:] Now BOTH a[1] and b[1] now identify the location of the inner list object, ["x", "y"] . Apparently, Python, in its ever efficient memory management fash

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 19Apr2015 15:09, Cameron Simpson wrote: On 18Apr2015 23:26, boB Stepp wrote: On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's "deepcopy" function, which supplies thi

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 18Apr2015 23:26, boB Stepp wrote: On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's "deepcopy" function, which supplies this for when it is needed: https://docs.pytho

Re: [Tutor] lists, name semantics

2015-04-18 Thread boB Stepp
On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: > Sometimes you want a "deep" copy, where "b" would have got a copy of the > iriginal x-y list. See the "copy" module's "deepcopy" function, which > supplies this for when it is needed: > > https://docs.python.org/3/library/copy.html#copy.

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 18Apr2015 22:03, Bill Allen wrote: On Apr 18, 2015 4:11 PM, "boB Stepp" wrote: On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: >> You can test your newfound knowledge by predicting the output of the >> following script:

Re: [Tutor] lists, name semantics

2015-04-18 Thread boB Stepp
On Sat, Apr 18, 2015 at 10:03 PM, Bill Allen wrote: > > On Apr 18, 2015 4:11 PM, "boB Stepp" wrote: >> >> On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: >> > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: >> > >> >> Bill Allen wrote: [...] >> >> You can test your newfound

Re: [Tutor] lists, name semantics

2015-04-18 Thread Bill Allen
On Apr 18, 2015 4:11 PM, "boB Stepp" wrote: > > On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: > > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: > > > >> Bill Allen wrote: > >> > >> > Everyone that responded, > >> > > >> > Thanks very much for the excellent explanations! T

Re: [Tutor] lists, name semantics

2015-04-18 Thread boB Stepp
On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: > >> Bill Allen wrote: >> >> > Everyone that responded, >> > >> > Thanks very much for the excellent explanations! The distinction between >> > a reference to an object and a sepe

Re: [Tutor] lists, name semantics

2015-04-18 Thread Bill Allen
print(b) will print the original copy of a which b now references which is [1, ["x", "y"], 3] On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: > Bill Allen wrote: > > > Everyone that responded, > > > > Thanks very much for the excellent explanations! The distinction between > > a

Re: [Tutor] lists, name semantics

2015-04-18 Thread Peter Otten
Bill Allen wrote: > Everyone that responded, > > Thanks very much for the excellent explanations! The distinction between > a reference to an object and a seperate copy of the object is quite clear > now. You can test your newfound knowledge by predicting the output of the following script:

Re: [Tutor] lists, name semantics

2015-04-18 Thread Bill Allen
Everyone that responded, Thanks very much for the excellent explanations! The distinction between a reference to an object and a seperate copy of the object is quite clear now. --Bill On Apr 18, 2015 1:44 AM, "Alan Gauld" wrote: > On 18/04/15 04:16, Bill Allen wrote: > >> If I have a list defi

Re: [Tutor] lists, name semantics

2015-04-17 Thread Alan Gauld
On 18/04/15 04:16, Bill Allen wrote: If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? These seem equivalent to me. Is that the case? Is there any nuance I am missing here? Situations where one form should be used

Re: [Tutor] lists, name semantics

2015-04-17 Thread Dave Angel
On 04/17/2015 11:51 PM, Ben Finney wrote: Ben Finney writes: Bill Allen writes: If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? ‘my_list’ is a reference to the object you've already described (the existing obje

Re: [Tutor] lists, name semantics

2015-04-17 Thread Ben Finney
Ben Finney writes: > Bill Allen writes: > > > If I have a list defined as my_list = ['a','b','c'], what is the is > > differnce between refering to it as my_list or my_list[:]? > > ‘my_list’ is a reference to the object you've already described (the > existing object ‘['a', 'b', 'c']’). > > ‘my_

Re: [Tutor] lists, name semantics

2015-04-17 Thread Martin A. Brown
Good evening Bill, If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? These seem equivalent to me. Is that the case? Is there any nuance I am missing here? Situations where one form should be used as opposed to th

Re: [Tutor] lists, name semantics

2015-04-17 Thread Ben Finney
Bill Allen writes: > If I have a list defined as my_list = ['a','b','c'], what is the is > differnce between refering to it as my_list or my_list[:]? ‘my_list’ is a reference to the object you've already described (the existing object ‘['a', 'b', 'c']’). ‘my_list[:]’ is an operation that takes

[Tutor] lists, name semantics

2015-04-17 Thread Bill Allen
If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? These seem equivalent to me. Is that the case? Is there any nuance I am missing here? Situations where one form should be used as opposed to the other? Thanks, Bill