Re: Python 2.1 out
On Thu, Apr 19, 2001 at 12:17:40PM +0200, Florian Weimer wrote:
| Gregor Hoffleit <gregor@mediasupervision.de> writes:
|
| [Python warning messages]
|
| > Could you mail an example of such a message ?
|
| y = None
| def fun():
| y = None
| def bar():
| y
| bar()
|
| fun()
|
| results in:
|
| <file>:2: SyntaxWarning: local name 'y' in 'fun' shadows use of 'y' as global in nested scope 'bar'
| def fun():
Yeah, that code will almost certainly break in 2.2 when nested scopes
become mandatory. It may have been intended, but assignment to a
local variable overshadowing a global is rarely the intended effect.
Anyways, if you want to get rid of those message now, without changing
the code use the -W option to the interpreter. Example :
$ python -W ignore Scope.py
(I created a file called Scope.py with that code in it)
See the last paragraph at
http://www.python.org/doc/current/lib/warning-filter.html
-D
Reply to: