[Python-bugs-list] [ python-Bugs-452154 ] globaling a variable twice issues warn
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 17 Aug 2001 11:11:39 -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: Andrew Csillag (drew_csillag)
Date: 2001-08-17 11:11
Message:
Logged In: YES
user_id=67436
I kinda agree that it's probably not worthwile to change the
compiler to handle this as it's probably a rare thing to
have happen. The main reason I had the second global
statement is that I del'd the global'd variable in between
and I wasn't sure if the global would stick. I guess I know
tha I don't have to worry about it now. :)
Thanks
----------------------------------------------------------------------
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