Re: Problem with objects copying each other in memory

2009-02-13 Thread Bruno Desthuilliers
Cameron Pulsford a écrit : Thanks, that did it! Why is that the case though? Or rather, why do the assignments to temp.x and temp.y not effect the self.x and self.y? How come I only run into the problem with the list? Because there's a huge difference between binding an object to a name and

Re: Problem with objects copying each other in memory

2009-02-12 Thread Rhodri James
On Thu, 12 Feb 2009 22:29:29 -, Cameron Pulsford wrote: Thanks, that did it! Why is that the case though? Or rather, why do the assignments to temp.x and temp.y not effect the self.x and self.y? How come I only run into the problem with the list? Variable names and assignment don't w

Re: Problem with objects copying each other in memory

2009-02-12 Thread andrew cooke
the official answer to that question is here - http://docs.python.org/reference/datamodel.html?highlight=containers - at about the 6th paragraph where it talks about "containers". i think it's a hard question and really in a sense (imho) the real reason is just that this tends to be the best comp

Re: Problem with objects copying each other in memory

2009-02-12 Thread Cameron Pulsford
Thanks, that did it! Why is that the case though? Or rather, why do the assignments to temp.x and temp.y not effect the self.x and self.y? How come I only run into the problem with the list? On Feb 12, 2009, at 5:15 PM, andrew cooke wrote: you're setting the new knight's "sl" to the value

Re: Problem with objects copying each other in memory

2009-02-12 Thread andrew cooke
you're setting the new knight's "sl" to the value self.sl and then adding values to it. that's the same list - so you are adding values to the self.sl list when you add them to the knight's sl. this is easier to understand just by seeing the fix, which is to use: temp = Knight(self.x, self.y, s

Re: Problem with objects copying each other in memory

2009-02-12 Thread Chris Rebert
On Thu, Feb 12, 2009 at 1:57 PM, dlocpuwons wrote: > Using Python 2.6.1... > > I am (attempting) to make an A* search for a chess problem, but I am > running into a really annoying shared memory issue in my successor > function. Here it is stripped down to the important parts that relate > to my p