I have a dictionnary with variable in it that I would like to get it in global variable.
example:
I was expecting from that to be able to call width*length*th k but I get glabal name error.
If I do:
I get the same error. But if I do this:
I just get whatever the last item have been use by my loop and not the other one. I know I can do this:
But when the dictionnary have over 375 item in it, it is not funny. Any idea how I could turn it into local variable or global variable?
example:
Code:
sketch_dict = { "width":48.0, "length":12.5, "thk":0.75 }
for it in sketch_dict:
if string.split( it, "__" )[0] == "":
pass
else:
global it
print it," = ",sketch_dict[ it ]
it = sketch_dict[ it ]
If I do:
Code:
print width
Code:
print it
Code:
print sketch_dict['width'] * sketch_dict['length'] * sketch_dict['thk']
Comment