Code Block Type | Global Namespace | Local Namespace |
---|---|---|
Module | n.s. for the module | same as global |
Script (file or command) | n.s. for __main__ | same as global |
Interactive command | n.s. for __main__ | same as global |
Class definition | global n.s. of containing block | new namespace |
Function body | global n.s. of containing block | new namespace |
String passed to exec statement | global n.s. of containing block | local namespace of containing block |
String passed to eval() | global n.s. of caller | local n.s. of caller |
File read by execfile() | global n.s. of caller | local n.s. of caller |
Expression read by input() | global n.s. of caller | local n.s. of caller |