storing variable names in a list before they are used?

jmdeschamps at gmail.com jmdeschamps at gmail.com
Fri Sep 29 16:08:01 EDT 2006


John Salerno wrote:
> 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.

Not sure but mmaybe this older post might help:
http://mail.python.org/pipermail/tutor/2005-January/035232.html

JM




More information about the Python-list mailing list