Module
PronunciationMOJ-ool
Definition
A module is a single file of code, such as money.py, whose functions and classes you can import and use in other files.
Where you hear it
In Python and JavaScript projects, whenever code is split into separate files, and in errors such as ModuleNotFoundError.
Examples
Put the date helpers in their own module.
The import fails because Python can't find the module.
The date helpers live in one module, so the report and the invoice both import them.
Common mistake
Naming your own file like a library module, such as random.py or json.py. It hides the real one.
Don't confuse with
A package, which is a folder that groups several modules together.
Say it at work
- In a meeting or chat
Let's split this into modules: one for money, one for dates.
- In an email or ticket
Which module defines this function?
Keep exploring
More in Programming Fundamentals