Re: unexpected behavior: did i create a pointer?

2007-09-12 Thread Bruno Desthuilliers
neoedmund a écrit : On Sep 7, 4:07 pm, gu [EMAIL PROTECTED] wrote: (snip pb and code) now, in the second for cycle and in functionA() i only 'touch' copyOfA (altering it). as i don't touch the variable a, i expect it not to be affected by any change, but copyOfA acts like a pointer to a and

Re: unexpected behavior: did i create a pointer?

2007-09-12 Thread Gabriel Genellina
En Wed, 12 Sep 2007 08:30:14 -0300, Bruno Desthuilliers [EMAIL PROTECTED] escribi�: neoedmund a écrit : On Sep 7, 4:07 pm, gu [EMAIL PROTECTED] wrote: (snip pb and code) now, in the second for cycle and in functionA() i only 'touch' copyOfA (altering it). as i don't touch the variable

Re: unexpected behavior: did i create a pointer?

2007-09-11 Thread Peter Otten
Am Sat, 08 Sep 2007 09:44:24 + schrieb Steven D'Aprano: Ways that Python objects are not like C pointers: (1) You don't have to manage memory yourself. (2) You don't have typecasts. You can't change the type of the object you point to. (3) Python makes no promises about the memory

Re: unexpected behavior: did i create a pointer?

2007-09-10 Thread neoedmund
On Sep 7, 4:07 pm, gu [EMAIL PROTECTED] wrote: hi to all! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the code to reproduce the

Re: unexpected behavior: did i create a pointer?

2007-09-09 Thread Arnaud Delobelle
On Sep 8, 10:44 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: [...] Ways that Python objects are like pointers: (1) ... um... Oh yeah, if you bind the _same_ object to two different names, _and_ the object is mutable (but not if it is immutable), mutating the object via

Re: unexpected behavior: did i create a pointer?

2007-09-09 Thread Steven D'Aprano
On Sun, 09 Sep 2007 02:30:00 -0700, Arnaud Delobelle wrote: You know, maybe because I came to Python with no C experience, I never had trouble with the unexpected behaviour that so confused the original poster. It's just obvious. The funny thing is that if the OP had thought of both 'a' and

Re: unexpected behavior: did i create a pointer?

2007-09-09 Thread Arnaud Delobelle
On Sep 9, 1:59 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 09 Sep 2007 02:30:00 -0700, Arnaud Delobelle wrote: You know, maybe because I came to Python with no C experience, I never had trouble with the unexpected behaviour that so confused the original poster.

Re: unexpected behavior: did i create a pointer?

2007-09-09 Thread Alex Martelli
Arnaud Delobelle [EMAIL PROTECTED] wrote: ... def lower_list(L): ... for i, x in enumerate(L): ... L[i] = x.lower() ... s = ['STRING'] lower_list(s) print s == ['string'] True def lower_string(s): ... s = s.lower() ... s = STRING lower_string(s)

Re: unexpected behavior: did i create a pointer?

2007-09-08 Thread Peter Otten
Am Sat, 08 Sep 2007 00:32:35 + schrieb Steven D'Aprano: On Fri, 07 Sep 2007 15:59:53 +0200, Wildemar Wildenburger wrote: I just thought I'd go along with the analogy the OP created as that was his mindset and it would make things easier to follow if I didn't try to forcibly change that.

Re: unexpected behavior: did i create a pointer?

2007-09-08 Thread Peter Otten
Am Fri, 07 Sep 2007 13:10:16 + schrieb Grant Edwards: On 2007-09-07, Peter Otten [EMAIL PROTECTED] wrote: Am Fri, 07 Sep 2007 10:40:47 + schrieb Steven D'Aprano: Python doesn't have any pointers. Thinking of python variables or names as pointers should get you a long way when

Re: unexpected behavior: did i create a pointer?

2007-09-08 Thread Steven D'Aprano
On Sat, 08 Sep 2007 10:07:14 +0200, Peter Otten wrote: Am Fri, 07 Sep 2007 13:10:16 + schrieb Grant Edwards: On 2007-09-07, Peter Otten [EMAIL PROTECTED] wrote: Am Fri, 07 Sep 2007 10:40:47 + schrieb Steven D'Aprano: Python doesn't have any pointers. Thinking of python variables

Re: unexpected behavior: did i create a pointer?

2007-09-08 Thread Wildemar Wildenburger
Dennis Lee Bieber wrote: On Fri, 07 Sep 2007 12:19:12 -0700, Steve Holden [EMAIL PROTECTED] declaimed the following in comp.lang.python: Since it's only a matter of time before someone brings up the post-It analogy, let me cavil in advance about it. The thing I don't like about that

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Wildemar Wildenburger
gu wrote: hi to all! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the code to reproduce the problem: [snip FAQ] Yes, basically

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Roel Schroeven
gu schreef: copyOfA = a now, in the second for cycle and in functionA() i only 'touch' copyOfA (altering it). copyOfA isn't a copy of a; it's a different name bound to the same object as a. You can verify that: id(a) and id(copyOfA) will return the same value. To make a copy of a

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 10:40:47 +, Steven D'Aprano wrote: Nor does it include peek and poke commands for reading and writing into random memory locations. I guess `ctypes` offers tools to write `peek()` and `poke()`. :-) Ciao, Marc 'BlackJack' Rintsch --

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Grant Edwards
On 2007-09-07, Peter Otten [EMAIL PROTECTED] wrote: Am Fri, 07 Sep 2007 10:40:47 + schrieb Steven D'Aprano: Python doesn't have any pointers. Thinking of python variables or names as pointers should get you a long way when trying to understand python's behaviour. But thinking of them as

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Peter Otten
Am Fri, 07 Sep 2007 10:40:47 + schrieb Steven D'Aprano: Python doesn't have any pointers. Thinking of python variables or names as pointers should get you a long way when trying to understand python's behaviour. As long as you keep in mind that python doesn't have pointers to pointers, and

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 11:46:38 +0200, Wildemar Wildenburger wrote: gu wrote: hi to all! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Dustan
On Sep 7, 3:07 am, gu [EMAIL PROTECTED] wrote: hi to all! Hi! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the code to reproduce the

unexpected behavior: did i create a pointer?

2007-09-07 Thread gu
hi to all! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the code to reproduce the problem: code a = {} for x in range(10): for y

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Wildemar Wildenburger
Steven D'Aprano wrote: On Fri, 07 Sep 2007 11:46:38 +0200, Wildemar Wildenburger wrote: gu wrote: hi to all! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 05:07:03 -0300, gu [EMAIL PROTECTED] escribi�: after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the code to reproduce

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steve Holden
Steven D'Aprano wrote: On Fri, 07 Sep 2007 11:46:38 +0200, Wildemar Wildenburger wrote: gu wrote: hi to all! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steve Holden
Grant Edwards wrote: On 2007-09-07, Peter Otten [EMAIL PROTECTED] wrote: Am Fri, 07 Sep 2007 10:40:47 + schrieb Steven D'Aprano: Python doesn't have any pointers. Thinking of python variables or names as pointers should get you a long way when trying to understand python's behaviour.

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 15:59:53 +0200, Wildemar Wildenburger wrote: I just thought I'd go along with the analogy the OP created as that was his mindset and it would make things easier to follow if I didn't try to forcibly change that. My reaction to somebody trying to reason with the wrong