A python program that I'm debugging has the following code (including print
statements for debugging):
print "BEFORE..."
print "oup[\"0\"] = " + str(oup["0"])
print "oup[\"2008\"] = " + str(oup["2008"])
print "oup[\"2009\"] = " + str(oup["2009"])
oup0 = oup["0"]
oup2008 = oup["2008"]
oup2009 = oup["2009"]
ouptotal = oup2008 + oup2009
print "ouptotal = " + str(ouptotal)
if ouptotal > 0:
oup["2008"] = oup2008 + oup0 * (oup2008 / ouptotal)
oup["2009"] = oup2009 + oup0 * (oup2009 / ouptotal)
print "AFTER..."
print "oup[\"0\"] = " + str(oup["0"])
print "oup[\"2008\"] = " + str(oup["2008"])
print "oup[\"2009\"] = " + str(oup["2009"])
Up until that point, the variables update correctly. When I run that code, I get the following on the screen:
BEFORE...
oup["0"] = 22032
oup["2008"] = 541
oup["2009"] = 15223
ouptotal = 15764
AFTER...
oup["0"] = 22032
oup["2008"] = 541
oup["2009"] = 15223
Why aren't oup["2008"] and oup["2009"] updating?
(Python version is 2.6.2 on a "Jaunty" Ubuntu machine.)