creating variable names by adding 2 strings?

Rainer Deyke root at rainerdeyke.com
Sun Jan 21 23:37:34 EST 2001


"Lee" <lee.reilly at ntlworld.com> wrote in message
news:3A6BAA32.370A2C00 at ntlworld.com...
> while (p!=0):
>         p+`p`= string.replace(component[control], ",", "")
>         # e.g. I want 'p1 = string.replace.blah...'

Why?  What's wrong with 'q[p] = ...'?  To answer your question, it's
impossible for local variables.  For global variables, assign to
'globals()['p' + p]'.  For attributes, use 'setattr'.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list