Views
Scope
-
the global scope of a function defined in a module is that module's namespace, no matter from where or by what alias the function is called
-
The global namespace for a module is created when the module definition is read in
-
statements executed by the top-level invocation of the interpreter, either read from a script file or interactively, are considered part of a module called __main__, so they have their own global namespace
Scope Ordering
-
the innermost scope consists of the local names and is searched first
-
the namespaces of any enclosing functions are then searched starting with the nearest enclosing scope
-
the middle scope, searched next, contains the current module's global names
-
the outermost scope (searched last) is the namespace containing built-in names
Loading Modules
-
current directory
-
PYTHONPATH
-
installation-dependent default
Built-ins
-
some functions are part of the global namespace and cannot be removed
-
math functions like abs()
-
technically, they are part of a module called __builtin__
References