Name
The global Statement
Synopsis
globalname
[,name
]*
Namespace declaration: inside a class or function, treats appearances
of name
as references to a global
(module-level) variable by that name—whether it is assigned or
not. Because of Python scope rules, you need to declare only global
names that are assigned within a def
(global
references are automatically found in the enclosing module).
Get Python Pocket Reference, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.