๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Python Beginner

What is Module?

A Python file containing definitions and statements that can be imported and reused in other Python programs.

A module is simply a .py file. It can define functions, classes, and variables. Modules promote code reuse and organization. Import with import module_name or from module import function.

Python comes with a rich standard library of modules (os, sys, json, datetime, etc.). Third-party modules are installed via pip. Packages are directories of modules with an __init__.py file.

Related Terms

Python Iterator Protocol
The interface requiring __iter__() and __next__() methods, enabling objects to be used in for loops and other iteration contexts.
Decorator
A function that modifies or extends the behavior of another function or class without changing its source code.
Pydantic
A data validation library that uses Python type annotations to validate and serialize data with automatic error reporting.
Docstring
A string literal placed as the first statement in a module, class, or function to document its purpose and usage.
Python Metaclass
A class whose instances are classes themselves โ€” the class of a class that controls how classes are created and behaved.
Logging Module
Python's built-in module for recording diagnostic information with configurable handlers, formatters, and log levels.
View All Python Terms โ†’