G|N|
January 26th, 2008, 06:41 AM
Hi,
I have a little programming problem:
I have a variable 'values' that holds a dictionary with values (user, password,...)
In the actual program i want them to be assigned dynamically like this:
#the values that were given to the class
values = {'name':'test', 'user': 'me', 'password': 'hello'}
name = ""
user = ""
password = ""
#the first is the label (the same as in values), the second is the variable
#where it has to be assigned to.
watch_values = [
['name', name],
['user', user],
['password', password]
]
watch_values[0][1] = values[watch_values[0][0]]
print watch_values[0][1]
print name
print user
print password
of course this does not work because my values['name'] is stored in watch_values[0][1] and not the variable that it held before.
Is there a way to assign it to the variable instead of watch_values?
I want to make a dynamic assignment so i can automatically check if all values are filled in.
I have a little programming problem:
I have a variable 'values' that holds a dictionary with values (user, password,...)
In the actual program i want them to be assigned dynamically like this:
#the values that were given to the class
values = {'name':'test', 'user': 'me', 'password': 'hello'}
name = ""
user = ""
password = ""
#the first is the label (the same as in values), the second is the variable
#where it has to be assigned to.
watch_values = [
['name', name],
['user', user],
['password', password]
]
watch_values[0][1] = values[watch_values[0][0]]
print watch_values[0][1]
print name
print user
print password
of course this does not work because my values['name'] is stored in watch_values[0][1] and not the variable that it held before.
Is there a way to assign it to the variable instead of watch_values?
I want to make a dynamic assignment so i can automatically check if all values are filled in.