Very Strange Problem
Omer Khalid
Omer.Khalid at cern.ch
Wed Jul 29 11:26:55 EDT 2009
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]['v'] == 0:
# set it to 1
jobs[index]['v'] = 1
print "Set to 1"
else:
print "Already set to 1"
loop():
index=0
for each in range(len(jobs)):
some_function(index)
index +=1
Apparently, the jobs[index]['v'] never get updated in the some_function but
the print statement afterwards get printed...
What's really surprising is that there are no errors or exceptions and my my
program runs in a single thread...so i have been unable to explain this
behavior.
Any insight would be much appreciated!
Cheers
Omer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090729/56133f08/attachment.html>
More information about the Python-list
mailing list