Re: Very Strange Problem

2009-07-30 Thread Simon Forman
On Wed, Jul 29, 2009 at 3:10 PM, Omer Khalid wrote: > Hi Dave, > > Thanks for your reply. I actually didn't cut and paste my code as it was > dispersed in different places, i typed the logic behind my code in the email > (and obiviously made some typos, indentations is some thing else) but my Plea

Re: Very Strange Problem

2009-07-29 Thread Dave Angel
in memory this object is stored, and is there a lock on it or else? Thanks, Omer ** On Wed, Jul 29, 2009 at 8:56 PM, Dave Angel wrote: Omer Khalid wrote: Hi, I am having a very strange problem with modifying a variable in a list in my progra

Re: Very Strange Problem

2009-07-29 Thread Terry Reedy
Omer Khalid wrote: Hi, I am having a very strange problem with modifying a variable in a list in my program. Here is the code: To me, this sentence clearly implies that the code that follows is the code that had the problem. Since the posted code cannot run, it clearly is not. People

Re: Very Strange Problem

2009-07-29 Thread Omer Khalid
t is stored, and is there a lock on it or else? Thanks, Omer ** On Wed, Jul 29, 2009 at 8:56 PM, Dave Angel wrote: > Omer Khalid wrote: > >> Hi, >> >> I am having a very strange problem with modifying a variable in a list in >&g

Re: Very Strange Problem

2009-07-29 Thread Dave Angel
Omer Khalid wrote: Hi, I am having a very strange problem with modifying a variable in a list in my program. Here is the code: # a list that contains dictionary objects jobs = [] index=5 for each in range(index): jobs.append({'v':0}) some_function(index): if jobs

Re: Very Strange Problem

2009-07-29 Thread MRAB
Ricardo Aráoz wrote: MRAB wrote: Omer Khalid wrote: Hi, I am having a very strange problem with modifying a variable in a list in my program. Here is the code: # a list that contains dictionary objects jobs = [] index=5 for each in range(index): jobs.append({'

Re: Very Strange Problem

2009-07-29 Thread MRAB
Omer Khalid wrote: Hi, I am having a very strange problem with modifying a variable in a list in my program. Here is the code: # a list that contains dictionary objects jobs = [] index=5 for each in range(index): jobs.append({'v':0}) some_function(index): if jobs

Very Strange Problem

2009-07-29 Thread Omer Khalid
Hi, I am having a very strange problem with modifying a variable in a list in my program. Here is the code: # a list that contains dictionary objects jobs = [] index=5 for each in range(index): jobs.append({'v':0}) some_function(index): if jobs[index]

Re: very strange problem in 2.4

2006-04-10 Thread conor . robinson
Ok, so I found out that even though mylist[] and all objects in it were fine ie id(mylist[i]) != id(mylist[all others]) what was happening is that during a reproduction function a shallow copies were being made making all offspring (genetic algorithm) have different id(mylist[0..n]), however the ac

Re: very strange problem in 2.4

2006-04-10 Thread conor . robinson
Ok, so I found out that even though mylist[] and all objects in it were fine ie id(mylist[i]) != id(mylist[all others]) what was happening is that during a reproduction function a shallow copies were being made making all offspring (genetic algorithm) have different id(mylist[0..n]), however the ac

Re: very strange problem in 2.4

2006-04-10 Thread conor . robinson
Ok, so I found out that even though mylist[] and all objects in it were fine ie id(mylist[i]) != id(mylist[all others]) what was happening is that during a reproduction function a shallow copies were being made making all offspring (genetic algorithm) have different id(mylist[0..n]), however the ac

Re: very strange problem in 2.4

2006-04-10 Thread conor . robinson
Ok, so I found out that even though mylist[] and all objects in it were fine ie id(mylist[i]) != id(mylist[all others]) what was happening is that during a reproduction function a shallow copies were being made making all offspring (genetic algorithm) have different id(mylist[0..n]), however the ac

Re: very strange problem in 2.4

2006-04-10 Thread conor . robinson
Ok, so I found out that even though mylist[] and all objects in it were fine ie id(mylist[i]) != id(mylist[all others]) what was happening is that during a reproduction function a shallow copies were being made making all offspring (genetic algorithm) have different id(mylist[0..n]), however the ac

Re: very strange problem in 2.4

2006-04-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > The Problem (very basic, but strange): > > I have a list holding a population of objects, each object has 5 vars > and appropriate funtions to get or modify the vars. Which are probably not necessary: http://dirtsimple.org/2004/12/python-is-not-java.html (in short:

Re: very strange problem in 2.4

2006-04-07 Thread Fredrik Lundh
John Zenger wrote: > Your list probably contains several references to the same object, > instead of several different objects. This happens often when you use a > technique like: > > list = [ object ] * 100 > > ..because although this does make copies when "object" is an integer, it > just makes

Re: very strange problem in 2.4

2006-04-07 Thread Ben Cartwright
John Zenger wrote: > Your list probably contains several references to the same object, > instead of several different objects. This happens often when you use a > technique like: > > list = [ object ] * 100 This is most likely what's going on. To the OP: please post the relevant code, including

Re: very strange problem in 2.4

2006-04-07 Thread Steven D'Aprano
On Fri, 07 Apr 2006 21:18:12 -0400, John Zenger wrote: > Your list probably contains several references to the same object, > instead of several different objects. This happens often when you use a > technique like: > > list = [ object ] * 100 > > ..because although this does make copies when

Re: very strange problem in 2.4

2006-04-07 Thread John Zenger
Your list probably contains several references to the same object, instead of several different objects. This happens often when you use a technique like: list = [ object ] * 100 ..because although this does make copies when "object" is an integer, it just makes references in other cases. [E

very strange problem in 2.4

2006-04-07 Thread conor . robinson
The Problem (very basic, but strange): I have a list holding a population of objects, each object has 5 vars and appropriate funtions to get or modify the vars. When objects in the list have identical vars (like all = 5 for var "a" and all = 10 for var "b" across all vars and objects) and i chang