Python Language Code block namespaces


Example

Code Block TypeGlobal NamespaceLocal Namespace
Modulen.s. for the modulesame as global
Script (file or command)n.s. for __main__same as global
Interactive commandn.s. for __main__same as global
Class definitionglobal n.s. of containing blocknew namespace
Function bodyglobal n.s. of containing blocknew namespace
String passed to exec statementglobal n.s. of containing blocklocal namespace of containing block
String passed to eval()global n.s. of callerlocal n.s. of caller
File read by execfile()global n.s. of callerlocal n.s. of caller
Expression read by input()global n.s. of callerlocal n.s. of caller