File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -972,10 +972,17 @@ as globals. It would be impossible to assign to a global variable without
972
972
:keyword: `!global `, although free variables may refer to globals without being
973
973
declared global.
974
974
975
- The :keyword: `global ` statement applies to the entire scope of a function or
976
- class body. A :exc: `SyntaxError ` is raised if a variable is used or
975
+ The :keyword: `!global ` statement applies to the entire current scope
976
+ (module, function body or class definition).
977
+ A :exc: `SyntaxError ` is raised if a variable is used or
977
978
assigned to prior to its global declaration in the scope.
978
979
980
+ At the module level, all variables are global, so a :keyword: `!global `
981
+ statement has no effect.
982
+ However, variables must still not be used or
983
+ assigned to prior to their :keyword: `!global ` declaration.
984
+ This requirement is relaxed in the interactive prompt (:term: `REPL `).
985
+
979
986
.. index ::
980
987
pair: built-in function; exec
981
988
pair: built-in function; eval
You can’t perform that action at this time.
0 commit comments