Browse by Topic

Popular

Latest

Latest Posts

Illustration of shallow and deep copy in Python showing nested objects and references.
Python

Python Object Copy: Shallow vs Deep Explained

Learn how to copy objects in Python correctly. Understand the difference between shallow and deep copy, when to use each, and how to customize copy behavior with `__copy__` and `__deepcopy__`.

shallow copydeep copycopy moduleobject reference
Diagram showing a Python namespace package spanning two directories on the import path without an __init__.py file
Python

Python Namespace Packages: Structure and Usage

Understand Python namespace packages: how they differ from regular packages, how PEP 420 import behavior works, and when to split a package across multiple distributions.

namespace packagesimport systempackagingPEP 420
Illustration of Python package structure with relative import dots indicating module relationships.
Python

Python Relative Imports in Packages: Syntax, Errors, and Fixes

Understand how relative imports work inside Python packages, why they fail when run directly, and how to structure modules for reliable imports.

relative importspython packagesimport errorsmodule resolution
Diagram of a Python project showing nested package directories and import arrows between subpackages.
Python

Python Subpackage Structure and Imports

How to structure Python subpackages, use relative imports, and avoid common import errors in larger projects.

Pythonsubpackageimportsrelative imports
A diagram showing Python package import resolution with folders and modules connected by arrows.
Python

Python Package Import: Syntax, Structure, and Pitfalls

python package import: Learn how Python resolves package imports, the role of __init__.py, and how to avoid common import errors with practical examples.

Python importsPackage structureRelative importsAbsolute imports
Illustration of a Python package directory with an __init__.py file marking it as a package.
Python

Python __init__.py: Purpose and Usage

Learn how Python's __init__.py works, when to use it, and how to avoid common pitfalls in package design.

pythonpackages__init__.pyimport
A visual diagram of a Python package directory tree showing modules, __init__.py, and import connections.
Python

Python Package Structure: Layout, Imports, and Packaging

A practical guide to Python package structure: directory layout, __init__.py files, import resolution, and preparing packages for distribution.

pythonmodule organizationrelative importspyproject.toml
Diagram of a Python package structure with pyproject.toml and src directory
Python

Python Packages: Structure, Build, and Publish

Practical guide to creating Python packages: project layout, pyproject.toml, editable installs, dependency management, and publishing to PyPI.

packagingpippyproject.tomlsetuptools
Illustration of Python importlib dynamically loading a module from a file path into a running program
Python

Using Python importlib for Dynamic Imports

python importlib: Learn how to use Python importlib for dynamic imports, module reloading, and custom importers with practical code examples.

dynamic importmodule reloadingimportlib.utilimport_module
A visual representation of a Python module object with its attributes, showing a box with labeled keys and values.
Python

Python Module Attributes: Definition, Access, and Common Pitfalls

Learn how Python module attributes are defined, accessed, and modified, including automatically set attributes, wildcard imports with __all__, and common pitfalls around imports and shared state.

module attributesPython imports__all__module-level variables