[Python-bugs-list] [ python-Bugs-452154 ] globaling a variable twice issues warn
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 17 Aug 2001 10:58:16 -0700
Bugs item #452154, was opened at 2001-08-17 09:53
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=452154&group_id=5470
Category: Parser/Compiler
Group: None
>Status: Closed
>Resolution: Wont Fix
Priority: 3
Submitted By: Andrew Csillag (drew_csillag)
Assigned to: Jeremy Hylton (jhylton)
Summary: globaling a variable twice issues warn
Initial Comment:
The following code generates a warning:
def foo():
global dammit
dammit = 5
global dammit
test.py:1: SyntaxWarning: name 'dammit' is assigned to
before global declaration def foo():
One would argue that this should still issue a warning,
but the warning it raises is a bit confusing
(especially when the two global statements are 100
lines apart).
----------------------------------------------------------------------
>Comment By: Jeremy Hylton (jhylton)
Date: 2001-08-17 10:58
Message:
Logged In: YES
user_id=31392
When you see the warning, you should remove the global
declaration that comes after the assignment. It doesn't
seem worthwhile to add extra complexity to the compiler to
handle this.
Maybe the function is too long if the two global decls are
100 lines apart <0.9 wink>.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=452154&group_id=5470