UnboundLocalError

Rob Williscroft rtw at freenet.co.uk
Thu Nov 9 21:32:42 CET 2006


Terry Reedy wrote in
news:mailman.1994.1163100168.11739.python-list at python.org in
comp.lang.python: 

>> def main():
>>    number = number()
> 
> Within a function, a given name can be either global or local, but not
> both.
> Here you are expecting the compiler to interpret the first occurance
> of 'number' as local and the second as global.  Humans can often
> resolve such ambiguities correctly, but not necessarily always.  So
> this is too much to ask of a program and hence it is not allowed.
> 

".. asked too much of the programme", sounds like a BOFH excuse to 
me ;-).

Seriously I'd bet (if I were a gambling man) that this is by design,
not either of "too much work for the interpreter" or "nobody's 
submitted a patch".

IOW: Why should the intepreter do more work just so the user 
can find new and interesting ways to shoot them selves in the foot.

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list