Unbound Local error? How?

Bruno Desthuilliers onurb at xiludom.gro
Tue Jun 27 11:32:02 EDT 2006


Hari Sekhon wrote:
> 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

this is *not* the traceback. This is only the error message. The
traceback contains all needed informations (or at least all possible
information at this point) to know what happened. But you did not post
the traceback. Nor did you post the minimal runnable code snippet
producing this error.

> 
> How?

How could we know ?


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list