Assignments and Variable Substitution

Evan Klitzke evan at yelp.com
Mon Aug 13 15:23:10 EDT 2007


On 8/13/07, brad <byte8bits at gmail.com> wrote:
> I'd like to do something like this:
>
> var = '123'
> %s = [], %var
>
> So that, in the end, var is '123' and an empty list is named '123' as
> well. The list assignments are created during a loop.

You can't assign a variable whose name is 123, but you can do this
sort of thing with setattr.

-- 
Evan Klitzke <evan at yelp.com>



More information about the Python-list mailing list