Computer Science
What is a package ? How is a package different from module ?
Python Libraries
4 Likes
Answer
A package is collection of Python modules under a common namespace, created by placing different modules on a single directory along with some special files (such as __init__.py).
Difference between package and module:
| Package | Module |
|---|---|
| A package is a collection of Python modules under a common namespace organized in directories. | A module is a single Python file containing variables, class definitions, statements and functions related to a particular task. |
| For a directory to be treated as a Python package, __init__.py (which can be empty) should be present. | __init__.py is not required for a Python module. |
| Packages can contain sub-packages, forming a nested structure. | Modules cannot be nested. |
Answered By
2 Likes