[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')
>>> globals()['name'] = 2
>>> name

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>

More information about the docs mailing list