[Python-Dev] restrictions on global statement

Jeremy Hylton jeremy@alum.mit.edu
Mon, 01 Apr 2002 16:24:53 -0500 (EST)

The lang ref says:

    Names listed in a \keyword{global} statement must not be defined
    as formal parameters or in a \keyword{for} loop control target,
    \keyword{class} definition, function definition, or
    \keyword{import} statement.

    (The current implementation does not enforce the latter two
    restrictions, but programs should not abuse this freedom, as
    future implementations may enforce them or silently change the
    meaning of the program.)

While this is all technically correct, the second paragraph is a bit
misleading.  The only case enforced by the compiler is that a formal
parameter can't be declared global.

Do we actually care about this rule?  The lang ref would be shorter if
it were silent on the issue, and it would more closely describe the
way Python has behaved as long as I've been using it.