Introduction
In programming, a module is a piece of software that has a specific functionality. As our program grows bigger, it may contain many lines of code. Instead of putting everything in a single file, we can use modules to separate codes in separate files as per their functionality. This makes our code organized and easier to maintain.
Packages are namespaces containing multiple packages and modules. They’re just directories, but with certain requirements.
In order to import a module/package we use the keyword import follow by the package name.
| |
Namespace in python are quick peculiar. We can call a specific function as well as a whole module.
| |
It can be memory heavy, but we can invoke all functions, variables and objects in a module/package natively in the environment with the * construct. We can also associate a package/module to a new name using the keyword structure:
import module name as new name
| |
The Python standard library contains well over 200 modules. We can import a module according to our needs.
A full example of a python code using most of the things seen just here. Taking advantages of the scientific (scipy), numerical (numpy), data visualisation (matplotlib) packages
| |

A more complex example using multiple packages and a special function for solving ODE’s (solve_ivp):
| |
