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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to