modulespackagesand distribution arge python programs are organized into modules and packages in additiona large number of modules are included in the python standard library this describes the module and package system in more detail in additionit provides information on how to install third-party modules and distribute source code modules and the import statement any python source file can be used as module for exampleconsider the following codespam py def foo()print(" ' foo and is %sadef bar()print(" ' bar and ' calling foo"foo(class spam(object)def grok(self)print(" ' spam grok"to load this code as moduleuse the statement import spam the first time import is used to load moduleit does three things it creates new namespace that serves as container for all the objects defined in the corresponding source file this is the namespace accessed when functions and methods defined within the module use the global statement it executes the code contained in the module within the newly created namespace it creates name within the caller that refers to the module namespace this name matches the name of the module and is used as followsimport spam spam spam foo( spam spam( grok(loads and executes the module 'spamaccesses member of module 'spamcall function in module 'spamcreate an instance of spam spam( lib fl ff