storing variable names in a list before they are used?

John Salerno johnjsal at NOSPAMgmail.com
Fri Sep 29 15:52:45 EDT 2006


If I want to have a list like this:

[(first_name, 'First Name:'), (last_name, 'Last Name:').....]

where the first part of each tuple is a variable name and the second 
part is a label for the user to see, such as a form like this:

First Name: ________
Last Name:  ________

(the variables would store whatever information is entered in the text 
boxes to the right of each label. I'm doing it this way so I can write a 
loop to construct my GUI components).

how would I go about putting these variable names in a list? I know I 
can't leave them as above, but if I put them in as a string, then how do 
I later "transform" them into an actual variable for assign, such as:

first_name = widget.get_text()

Is there some kind of idiom that does this sort of work?

Thanks.



More information about the Python-list mailing list