Re: [Tutor] pointer puzzlement

2015-05-08 Thread Dave Angel
On 05/08/2015 06:26 PM, Alan Gauld wrote: On 08/05/15 19:10, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 18:42, Dave Angel wrote: Python doesn't have pointers So what is the difference between a python name and a pointer? OK, This could get deepo. Lets start with the supoerficial...

Re: [Tutor] pointer puzzlement

2015-05-08 Thread Alan Gauld
On 08/05/15 19:10, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 18:42, Dave Angel wrote: Python doesn't have pointers So what is the difference between a python name and a pointer? OK, This could get deepo. Lets start with the supoerficial... A pointer (in most languiages) is a named

Re: [Tutor] pointer puzzlement

2015-05-08 Thread Dave Angel
On 05/08/2015 02:10 PM, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 18:42, Dave Angel wrote: Python doesn't have pointers So what is the difference between a python name and a pointer? I'm a bit fuzzy on that. What's the difference between a painting of Obama and a living state Senat

Re: [Tutor] pointer puzzlement

2015-05-08 Thread Jim Mooney Py3.4.3winXP
On 7 May 2015 at 18:42, Dave Angel wrote: > Python doesn't have pointers So what is the difference between a python name and a pointer? I'm a bit fuzzy on that. -- Jim "What a rotten, failed experiment. I'll start over. Maybe dogs instead of monkeys this time." --God ___

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Steven D'Aprano
On Thu, May 07, 2015 at 12:15:42PM -0700, Jim Mooney Py3.4.3winXP wrote: > I find this a bit confusing. Since the ID of K remains the same, so it's > the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I > understand that it's immutable but doesn't that mean K is created each time

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 07:51 PM, Dave Angel wrote: On 05/07/2015 04:54 PM, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 13:03, Emile van Sebille wrote: Compare to: def testid(K=100): K += 10 return 'the ID is', id(K), K Ah, thanks. I forgot small integers are saved in a table. I

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 05:25 PM, Alan Gauld wrote: On 07/05/15 21:54, Jim Mooney Py3.4.3winXP wrote: Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to defaults in function parameters are persistent. But remember they variables are NOT pointers. They are

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 04:54 PM, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 13:03, Emile van Sebille wrote: Compare to: def testid(K=100): K += 10 return 'the ID is', id(K), K Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to def

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 03:15 PM, Jim Mooney Py3.4.3winXP wrote: I find this a bit confusing. Since the ID of K remains the same, so it's the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I understand that it's immutable but doesn't that mean K is created each time in local scope so it

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 04:03 PM, Emile van Sebille wrote: On 5/7/2015 12:15 PM, Jim Mooney Py3.4.3winXP wrote: I find this a bit confusing. Since the ID of K remains the same, so it's the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I understand that it's immutable but doesn't that m

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Alan Gauld
On 07/05/15 21:54, Jim Mooney Py3.4.3winXP wrote: Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to defaults in function parameters are persistent. But remember they variables are NOT pointers. They are keys in a dictionary. Very different. Als

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Jim Mooney Py3.4.3winXP
On 7 May 2015 at 13:03, Emile van Sebille wrote: > Compare to: > > def testid(K=100): > K += 10 > return 'the ID is', id(K), K > Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to defaults in function parameters are persistent. It use

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Emile van Sebille
On 5/7/2015 12:15 PM, Jim Mooney Py3.4.3winXP wrote: I find this a bit confusing. Since the ID of K remains the same, so it's the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I understand that it's immutable but doesn't that mean K is created each time in local scope so it sh

[Tutor] pointer puzzlement

2015-05-07 Thread Jim Mooney Py3.4.3winXP
I find this a bit confusing. Since the ID of K remains the same, so it's the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I understand that it's immutable but doesn't that mean K is created each time in local scope so it should have a different ID each time? def testid(K=10):