Create a variable "on the fly"
Dan
dan at cellectivity.com
Wed Jul 27 12:51:06 EDT 2005
> make_variable('OSCAR', 'the grouch');
> print OSCAR;
Try using "setattr". (It's in __builtins__; you don't have to import
anything.)
>>> print setattr.__doc__
setattr(object, name, value)
Set a named attribute on an object; setattr(x, 'y', v) is equivalent to
``x.y = v''.
--
If builders built buildings the way programmers write programs,
the first woodpecker that came along would destroy civilization.
- Original author unknown
More information about the Python-list
mailing list