Difference between python module and python package?

What’s the difference between a Python module and a Python package?

Module:  It is a simple Python file that contains collections of functions and global variables and has a “.py”  extension file. It’s an executable file and we have something called a “Package” in Python to organize all these modules.

Package:  It is a simple directory which has collections of modules, i.e., a package is a directory of Python modules containing an additional init.py  file. It is the init.py  which maintains the distinction between a package and a directory that contains a bunch of Python scripts. A Package simply is a namespace. A package can also contain sub-packages.

When we import a module or a package, Python creates a corresponding object which is always of type module . This means that the dissimilarity is just at the file system level between module and package.

#technology #python #what's the difference between a python module and a python package? #python package #python module

Difference Between Python Module and Python Package?
2.00 GEEK