Modules vs Packages vs Libraries vs Frameworks

Modules vs Packages vs Libraries vs Frameworks

  Data visualization

Table of Contents

Python Module

A Python module is just a python file with a .py extension. It can contain variables or functions – elements that can be referred from another python file using an import.

For example, let’s create a simple python file – in a directory.

It just has a variable name and a function nameCapitalize(name). These can be referenced in another file using the standard import process that we already know.

Say, we create another file and then import using

import user

That’s it, the variable name inside the module can be referenced using the familiar dot (.) notation.

You can even reference the functions inside the referenced module.


Python Package

A python package is just a collection of Python files (or modules). Earlier, we were able to import a specific python file. Now, we have created a folder called customers and inside it created another python file(or module) called

You can have any levels of hierarchy inside a package using folders for nesting python modules.

Python Library

A python library is a collection of python packages. The python standard library for example is a collection of Python Packages. Theoritically, there is no difference between a Python Module and Python Package. Typically python library is a collection of modules or packages. For example, you can view the requests library here

Python Framework

A framework is a collection of python libraries. Some examples of popular python frameworks are

  • django – used to build web apps
  • flask – used to build APIs
  • FastAPI – used to build APIs

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: