Re: [Zope] [python] creating variable names by adding 2 strings?

2001-01-22 Thread Dieter Maurer
Lee writes: I'm creating variables in python but I am having trouble creating them when they're *named* using other variables. Here's an example; while (p!=0): p+`p`= string.replace(component[control], ",", "") # e.g. I want 'p1 = string.replace.blah...'

[Zope] [python] creating variable names by adding 2 strings?

2001-01-21 Thread Lee
Hi there, I'm creating variables in python but I am having trouble creating them when they're *named* using other variables. Here's an example; while (p!=0): p+`p`= string.replace(component[control], ",", "") # e.g. I want 'p1 = string.replace.blah...' p=p-1

Re: [Zope] [python] creating variable names by adding 2 strings?

2001-01-21 Thread Steve Spicklemire
Hi Lee, You could use a dictionary for this: vars = {} while (p!=0): vars['p'+`p`] = string.replace(component[control], ",", "") p=p-1 control=control+1 then 'vars' will contain keys (e.g., 'p1', 'p2' etc.. ) and corresponding values. If that's totally not what