variable hell

Peter Maas peter at somewhere.com
Fri Aug 26 05:57:10 EDT 2005


Benji York schrieb:
>>  >>> suffix = 'var'
>>  >>> vars()['a%s' % suffix] = 45
>>  >>> avar
>> 45
> 
> 
> Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about 
> the "vars" built in:
> 
> The returned dictionary should not be modified: the effects on the 
> corresponding symbol table are undefined.

I tried this once and it worked. This may be too naive, so thanks
for the warning :)

-- 
-------------------------------------------------------------------
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------



More information about the Python-list mailing list