Hi John

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

What scope do you want these variable names to show up in? For example, 
if you want them to be defined in the global scope then you can do the 
following:

name = 'first_name'

globals()[name] = widget.get_text()

print first_name


If you want these variables to be assigned to an object then you can use 
setattr():


name = 'first_name'

setattr(obj,name,widget.get_text())

print obj.first_name


Hope this helps

-Farshid
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to