How do I avoid this global SyntaxWarning?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sat Aug 25 12:21:58 EDT 2001


Sat, 25 Aug 2001 17:47:30 +0200, gradha at iname.com <gradha at iname.com> pisze:

> ./test.py:0: SyntaxWarning: name 'expresion_include' is assigned to before global declaration

'global' declarations at module scope do nothing. The warning makes
sense at function scope, where a programmer could expect that code
above the 'global' declaration refers to a local variable.

Solution: remove the 'global' declaration. The warning should perhaps
be changed to "global declaration is redundant at module scope" (after
it is taught to distinguish between these cases).

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list