[Python-Dev] more timely detection of unbound locals
Eli Bendersky
eliben at gmail.com
Mon May 9 17:06:18 CEST 2011
> x = 5
> def foo ():
> print (x)
> if bar ():
> x = 1
> print (x)
>
I wish you'd annotate this code sample, what do you intend it to
demonstrate?
It probably shows the original complaint even more strongly. As for being a
problem with the suggested solution, I suppose you're right, although it
doesn't make it much different. Still, before a *possible* assignment to
'x', it should be loaded as LOAD_NAME since it was surely not bound as
local, yet.
Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110509/82d1a583/attachment.html>
More information about the Python-Dev
mailing list