I've got some code as follows:
import re
re_regexname = re.compile('abc')
.....
..... various function defs
.....
def func1():
...
func2()
...
def func2():
if re_regexname.match('abc'):
<do something>
if __name__ == '__main__':
func1()
but this returns the Traceback:
UnboundLocalError: local variable 're_regexname' referenced before
assignment
How?
It was declared in the zero level indentation near the top of the
script! I don't understand this, isn't a function supposed to be able to
reference stuff in the containing function or the top level?
--
http://mail.python.org/mailman/listinfo/python-list