import from __future__
allows you to access new features which are not currently compatable with the current interpreter
import __future__
module allows you to see when features were added and became default with __future__.<feature>
In python, .py files are modules of definitions and statements
__name__
is the name of the modulefrom <module> import *
will import names from a module into the importing module's symbol table_
are not importedif __name__ == "__main__"
allows you to make a module both a usable script and a module to be imported.py
file in sys.path
dir()
is used to find out which names a module definesPackages provide namespacing for modules, like A.B
for package A
and submodule B
__init__.py
initializes a package (in its current directory, based on the directory name)import item.subitem.subsubitem
__init__.py
, a list named __all__
is the list of submodules to be imported when from <package> import *
is calledfrom .. import <submodule>
tensorflow
directory defines the package__init__.py
imports 3.x absolute_import, division and print_function from __future__
from tensorflow.python import *
, which imports the list defined by __all__
in the tensorflow.python packagepython/__init__.py
imports from tensorflow.core, tensorflow.framework, and sets default environment variables, and global default config