Skip to content
UPEEC

Typing and Program Structure

dataclasses, typing, abc and contextlib.

Easy
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (4)

dataclasses (module)

Generates boilerplate for data-holding classes: init, repr, eq, ordering, frozen instances, slots.

Easy♥ 0🔖 0💬 0

typing

Type-hint building blocks: Any, Optional, Union, Callable, TypeVar, Protocol, TypedDict, Literal, Final and more.

Intermediate♥ 0🔖 0💬 0

abc

Abstract base classes and @abstractmethod for defining interfaces.

Intermediate♥ 0🔖 0💬 0

contextlib

Helpers for context managers: @contextmanager, suppress, ExitStack, redirect_stdout, nullcontext.

Intermediate♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.