Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ======Python Modules and Packages====== * A Python module is a file containing Python code. * A package is a group of modules in a subdirectory. * To make a directory package include a file in the directory named //__init__.py//. ======Example===== To create a package //foo// that contains a module //bar// and function //hello//. <code> from foo.bar import hello hello() </code> Directory named //foo// contains empty file named //__init.py__// and file named //bar.py//. The file contains the function //hello//. General scheme <code> from <package>.<sub package>.<module> import <function/class> </code> The //__init__.py// could contain the following import statement. <code> from <package>.<module> import <function/class> </code> Which would allow the module to be imported into other modules with the following import statement that imports directly from the package and not the module. <code> from <package> import <function/class> </code> python_modules_and_packages.txt Last modified: 2017/10/25 12:33by mgupton