Interview Question

What are packages in Python?

Packages organize related modules into dotted namespaces.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

A Python package organizes modules under a dotted module name. • Traditional packages are directories containing __init__.py. • Namespace packages can span directories without __init__.py. • Importing a submodule uses names such as package.module.

💡 Simple Example

from email import message print(message.__name__)

Output

email.message

⚡ Quick Revision

Packages organize related modules into dotted namespaces.