In programming, a module is a piece of software that has a specific functionality. For example, when building a sudoku game, one module would be responsible for the game logic, and another module would be responsible for drawing the game on the screen. Each module is a different file, which can be edited separately.
Importing modules is similar to importing functions and is done by writing import <name of the module> . Every Python file can be referenced as a module. The module can contain functions, as already described, but also variables of all types (arrays, dictionaries, objects etc):
So the steps you do are:
- Save your code in a file e.g. like “myfirstmodule.py” (Notice: it is has to be in the same directory as your main file)
- Import your module: watch my blog post Mastery 07 for the different options on how to import libraries and functions, it is the same here.
- Use the module for your purposes in your current code.
With this knowlegde you can directly start. If you want to go more into detail I can recommend this page: https://www.w3schools.com/python/python_modules.asp