strings question

Andrew Koenig ark at
Sat Mar 13 06:26:19 CET 2004

"Faheem Mitha" <faheem at> wrote in message
news:slrnc53uq9.2lu.faheem at

> If I am given two strings, named foo and bar, what is the most elegant
> way to create a string object whose name is the value of foo and whose
> value is the value of bar?

The most elegant way might be to avoid altogether the notion of computing
variable names and use a dict instead.  It is unlikely that you really want
to be able to comput a variable name on the fly, because what happens if the
resulting variable happens to clash with a name that you are already using?

If you could say a little more about your application, perhaps we could tell
you more.

More information about the Python-list mailing list