Dynamic variable names ... with imported libraries.
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Thu May 15 21:14:36 EDT 2003
> From: Loko [mailto:Loko at caramail.com]
>
> --------------------
> >>> var = 'spam'
> >>> locals()[var] = 'eggs'
> >>> spam
> 'eggs'
> -------------------
Read and understand the warning below before you go any further down this path ...
2.3 Built-in Functions
locals()
Return a dictionary representing the current local symbol table.
Warning: The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter.
Tim Delaney
More information about the Python-list
mailing list