2.1 nested scope SyntaxWarning
John J. Lee
jjl at pobox.com
Sat Nov 3 21:44:34 CET 2001
Upgrading to Python 2.1, I find my old 2.0 code works fine, but I'm getting
warnings like the following:
SyntaxWarning: local name 'grace_np' in 'define_grace_np' shadows use of
'grace_np' as global in nested scope 'GracePlotter'
SyntaxWarning: local name 'qt' in 'QwtPlotter' shadows use of 'qt' as global in
nested scope 'hardcopy'
This is with code like the following (no from __future__ import x statements):
if self._initialised == 0:
self._g = grace_np.GraceProcess()
Now that I come to think about it, I'm not entirely sure what's going on when
you run this in 2.0, or in 2.1 without from __future__ import nested_scopes. I
don't see why grace_np should be visible as a local variable in the
GracePlotter class, given that the following:
a = 1
causes a NameError on 'print a', as does this:
a = 1
bar = foo()
b = bar()
However, the GracePlotter class works fine. Why?
Thanks for any help.
More information about the Python-list