What is the difference between Python’s Module, Package and Library?
Module: The module is a simple Python file that contains collections of functions and global variables and with having a
.py extension file. It is an executable file and to organize all the modules we have the concept called Package in Python.
Example: Save the code in file called demo_module.py
Import module named demo_module and call myModule function inside it.
This is My Module : Math
Package: The package is a simple directory having collections of modules. This directory contains Python modules and also having
__init__.py file by which the interpreter interprets it as a Package. The package is simply a namespace. The package also contains sub-packages inside it.
Student(Package) | __init__.py (Constructor) | details.py (Module) | marks.py (Module) | collegeDetails.py (Module)
Library: The library is having a collection of related functionality of codes that allows you to perform many tasks without writing your code. It is a reusable chunk of code that we can use by importing it in our program, we can just use it by importing that library and calling the method of that library with
Example: Importing pandas library and call read_csv method using alias of pandas i.e. pd.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course