[docs] [issue10043] UnboundLocalError with local variable set by setattr, caused by code run later

Terry J. Reedy report at bugs.python.org
Sat Oct 9 01:55:23 CEST 2010


Terry J. Reedy <tjreedy at udel.edu> added the comment:

The usual way to set a module variable by name, rather than
setattr(modules[__name__], 'name', 'value')
is
>>> globals()['name'] = 2
>>> name
2

Issues of working with external names, such as from database columns, has been discussed several times on python-list and the corresponding newsgroups. Please post there is you want to discuss that.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10043>
_______________________________________


More information about the docs mailing list