HiveBrain v1.2.0
Get Started
← Back to all entries
gotchapythonCriticalCanonical

What's the difference between a module and package in Python?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
modulepackageandbetweenthedifferencewhatpython

Problem

What's the difference between a module and package in Python?

See also: What's the difference between "package" and "module"? (for other languages)

Solution

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

Code Snippets

import my_module
from my_package.timing.danger.internets import function_of_love

Context

Stack Overflow Q#7948494, score: 458

Revisions (0)

No revisions yet.