gotchapythonCriticalCanonical
What's the difference between a module and package in Python?
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)
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.
A package is a collection of modules in directories that give a package hierarchy.
Documentation for modules
Introduction to packages
e.g.
import my_moduleA package is a collection of modules in directories that give a package hierarchy.
from my_package.timing.danger.internets import function_of_loveDocumentation for modules
Introduction to packages
Code Snippets
import my_modulefrom my_package.timing.danger.internets import function_of_loveContext
Stack Overflow Q#7948494, score: 458
Revisions (0)
No revisions yet.