๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_modules.asp
Python Modules
Python Examples Python Compiler ... Interview Q&A Python Bootcamp Python Certificate Python Training ... Consider a module to be the same as a code library....
๐ŸŒ
Learn Python
learnpython.org โ€บ en โ€บ Modules_and_Packages
Modules and Packages - Learn Python - Free Interactive Python Tutorial
To use the function draw_game from the draw module, we need to specify in which module the function is implemented, using the dot operator. To reference the draw_game function from the game module, we need to import the draw module and then call draw.draw_game(). When the import draw directive runs, the Python interpreter looks for a file in the directory in which the script was executed with the module name and a .py suffix.
๐ŸŒ
Real Python
realpython.com โ€บ python-modules-packages
Python Modules and Packages โ€“ An Introduction โ€“ Real Python
March 21, 2024 - Browse Topics Guided Learning Paths Basics Intermediate Advanced ยท ai algorithms api best-practices career community databases data-science data-structures data-viz devops django docker editors flask front-end gamedev gui machine-learning news numpy projects python stdlib testing tools web-dev web-scraping ... This article explores Python modules and Python packages, two mechanisms that facilitate modular programming.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ modules.html
6. Modules โ€” Python 3.14.4 documentation
Contrarily, when using syntax like import item.subitem.subsubitem, each item except for the last must be a package; the last item can be a module or a package but canโ€™t be a class or function or variable defined in the previous item. Now what happens when the user writes from sound.effects import *? Ideally, one would hope that this somehow goes out to the filesystem, finds which submodules are present in the package, and imports them all.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_module_built-in.asp
Python Built-in Modules
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... There are several built-in modules in Python, which you can import whenever you like.
๐ŸŒ
W3Schools
w3schools.in โ€บ python โ€บ modules
Python Modules - W3Schools
*Defining Modular Programming In Python *Roles Of Python Module *import Statement *Standard Library Modules In Python *How import Works?
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ what-is-the-difference-between-pythons-module-package-and-library
What is the difference between Python's Module, Package and Library? - GeeksforGeeks
July 15, 2025 - ... The package is a simple directory having collections of modules. This directory contains Python modules and also having __init__.py file by which the interpreter interprets it as a Package.
Top answer
1 of 10
807
  • Any Python file is a module, its name being the file's base name without the .py extension.
  • A package is a collection of Python modules: while a module is a single Python file, a package is a directory of Python modules containing an additional __init__.py file, to distinguish a package from a directory that just happens to contain a bunch of Python scripts. Packages can be nested to any depth, provided that the corresponding directories contain their own __init__.py file.

The distinction between module and package seems to hold just at the file system level. When you import a module or a package, the corresponding object created by Python is always of type module. Note, however, when you import a package, only variables/functions/classes in the __init__.py file of that package are directly visible, not sub-packages or modules.


Example

As an example, consider the xml package in the Python standard library: its xml directory contains an __init__.py file and four sub-directories; the sub-directory etree contains an __init__.py file and, among others, an ElementTree.py file.

See what happens when you try to interactively import package/modules:

>>> import xml
>>> type(xml)
<type 'module'>
>>> xml.etree.ElementTree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'etree'
>>>
>>>
>>> import xml.etree
>>> type(xml.etree)
<type 'module'>
>>> xml.etree.ElementTree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ElementTree'
>>>
>>>
>>> import xml.etree.ElementTree
>>> type(xml.etree.ElementTree)
<type 'module'>
>>> xml.etree.ElementTree.parse
<function parse at 0x00B135B0>

NOTE

In Python there also are built-in modules, such as sys, that are written in C, but I don't think you meant to consider those in your question.

2 of 10
458

A module is a single file (or files) that are imported under one import and used. e.g.

import my_module

A package is a collection of modules in directories that give a package hierarchy.

from my_package.timing.danger.internets import function_of_love

Documentation for modules

Introduction to packages

Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_pip.asp
Python PIP
A package contains all the files you need for a module. Modules are Python code libraries you can include in your project. Navigate your command line to the location of Python's script directory, and type the following:
๐ŸŒ
Python 101
python101.pythonlibrary.org โ€บ chapter36_creating_modules_and_packages.html
Chapter 36 - Creating Modules and Packages โ€” Python 101 1.0 documentation
You can leave both __init__.py files blank, but then youโ€™ll have to write code like mymath.add.add(x,y) which is pretty ugly, so weโ€™ll add the following code to the outer __init__.py to make using our package easier to understand and use. # outer __init__.py from . add import add from . divide import division from . multiply import multiply from . subtract import subtract from .adv.sqrt import squareroot ยท Now we should be able to use our module once we have it on our Python path.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_ref_modules.asp
Python Standard Library Modules (3.13)
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... This page lists the built-in modules that ship with the Python 3.13 Standard Library.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-packages
Python Packages - GeeksforGeeks
4 days ago - Allows modules to be easily shared and distributed across different applications. Module: A single Python file containing reusable code (e.g., math.py). Package: A directory containing modules and a special __init__.py file.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_pip_packages.asp
Python PIP Packages
Built-in Modules Random Module ... Training ... Downloading a package is very easy. Open the command line interface and tell PIP to download the package you want....
๐ŸŒ
SitePoint
sitepoint.com โ€บ blog โ€บ programming โ€บ understanding modules and packages in python
Understanding Modules and Packages in Python โ€” SitePoint
January 24, 2024 - Learn how to structure Python code by creating modules, defining functions and classes, creating packages, importing modules, and more.
๐ŸŒ
Python Course
python-course.eu โ€บ python-tutorial โ€บ packages.php
31. Packages | Python Tutorial | python-course.eu
November 8, 2023 - Packages are a way of structuring Pythonโ€™s module namespace by using "dotted module names". A.B stands for a submodule named B in a package named A. Two different packages like P1 and P2 can both have modules with the same name, let's say A, for example. The submodule A of the package P1 and the submodule A of the package P2 can be totally different.
๐ŸŒ
Medium
medium.com โ€บ @sjalexandre โ€บ python-tutorial-unit-22-a55a7d07f023
Python Tutorial โ€” Modules, Packages and Libraries | Medium
August 13, 2023 - In this unit, we will explore how to organize Python code using modules, packages, and libraries. Weโ€™ll learn how to create, use, and import these components to enhance code reusability and maintainability.
๐ŸŒ
Readthedocs
pythontutorials.readthedocs.io โ€บ en โ€บ latest โ€บ 02_01_Modules&Packages.html
Modules and Packages โ€” Python Tutorials documentation
The functions that we used so far ... of Python. We combined these functions to create our own custom predefined sequences of coding that we can call whenever we need them. In some cases, individuals or groups of people develop functions that are very useful to others. By collecting the definitions of these functions in one .py file, they can easily be shared. This file is then called a module. A package is a way of ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_module_create.asp
Python Create Module
To create a module just save the code you want in a file with the file extension .py: ... Note: When using a function from a module, use the syntax: module_name.function_name. Python Modules Tutorial Variables in Modules Renaming a Module Built-in Modules Using the dir() Function Import From Module
๐ŸŒ
Syskool
syskool.com โ€บ home โ€บ python modules and packages: a comprehensive deep dive for beginners and professionals
Python Modules and Packages: A Comprehensive Deep Dive for Beginners and Professionals - Syskool
April 27, 2025 - Think of a package as a folder, and modules as files inside it. ... Hello from module1! The __init__.py file tells Python that the directory should be treated as a package.