which consists of subpackages and modules. § It helps you maintain a program structure and framework by grouping similar modules in one package. § Package is like other directories on your system. A python package has a particular file “__init__.py“ which helps python identify that it is a package. § Use default packages from python official repository. www.pypi.org
you have to use repetitive piece of code again and again. § Packages are the code repository for managing your modules, functions and data. § Create modules when you need to share functions/ data with other team members or maybe with other python members.
python modules: § Import myPackage.myModule : Import a specific module from the respective package. § from myPackage import myModule : Alternative way of importing a specific module from the respective package. § from myPackage. myModule import func1,func2 : Import specific functions from myModule in the package.
subpackage. from myPackage.subpackage.myModule import func1,func2 Import specific functions from myModule in the subpackage. from myPackage.myModule import * import all the functions and data from the module. (Works only when __all__ is defined in __init__.py file) Importing Python Package: