PCPP1 study materials
PCPP1 study resources

PCPP1 key terms

PCPP1 · Get comfortable with the vocabulary.

metaclass

A class whose instances are themselves classes. It controls how a class object is created and can inject or modify methods and attributes at class-creation time, most often by subclassing type.

Related: type.__new__, abstract base class, __init_subclass__
__init_subclass__

A classmethod-like hook defined on a parent class that runs whenever a subclass is created. It lets a base class validate or configure subclasses without writing a custom metaclass.

Related: metaclass, class decorator
abstract base class

A class that cannot be instantiated until its abstract methods are overridden. Built with the abc module, it documents an interface and enforces implementation through the ABCMeta metaclass and @abstractmethod.

Related: @abstractmethod, virtual subclass, metaclass
@abstractmethod

A decorator marking a method that subclasses must override. Instantiating a class that still has unimplemented abstract methods raises TypeError at runtime.

Related: abstract base class, NotImplementedError
virtual subclass

A class registered with an abstract base class via register() or subclasshook so that isinstance and issubclass report it as a subclass without inheritance. No methods are actually inherited.

Related: abstract base class, __subclasshook__
__subclasshook__

A classmethod on an abstract base class that lets issubclass decide membership structurally, for example by checking for a particular method name, instead of relying on explicit registration.

Related: virtual subclass, abstract base class
method resolution order

The linearized order Python uses to look up attributes across a class's inheritance graph. Computed by the C3 algorithm and exposed as the mro attribute; it resolves diamond inheritance deterministically.

Related: super(), cooperative multiple inheritance
super()

A built-in returning a proxy that delegates attribute lookup to the next class in the method resolution order. In cooperative multiple inheritance it forwards calls along the chain rather than jumping to a fixed parent.

Related: method resolution order, cooperative multiple inheritance
cooperative multiple inheritance

A design pattern where each class in a hierarchy calls super() with matching signatures so every sibling's method runs exactly once, following the method resolution order.

Related: super(), method resolution order
descriptor

An object defining get, set, or delete that customizes attribute access on a class. Functions, properties, classmethods, and staticmethods are all descriptors.

Related: property, data descriptor, __set_name__
data descriptor

A descriptor that defines set or delete, giving it priority over entries in the instance dict during attribute lookup. Functions are non-data descriptors because they only define get.

Related: descriptor, property
__set_name__

A hook called automatically on every descriptor in a class body when the owning class is created, receiving the owner class and the attribute name. Useful for caching the attribute name.

Related: descriptor, metaclass
property

A built-in descriptor that turns getter, setter, and deleter methods into managed attributes. Accessing the attribute invokes the getter, so validation and computed values stay transparent to callers.

Related: descriptor, data descriptor
__slots__

A class attribute listing permitted instance attribute names, replacing the per-instance dict with fixed storage. It reduces memory use and blocks assignment of undeclared attributes.

Related: descriptor, __dict__
__dict__

The namespace dictionary holding an object's writable attributes. Instances normally have one; classes use it for their own attributes, and it is absent on instances of classes defining slots.

Related: __slots__, descriptor
dunder method

A special method with double leading and trailing underscores, such as len or add, invoked implicitly by Python syntax and built-in functions rather than called directly by name.

Related: operator overloading, __call__
operator overloading

Implementing dunder methods like add, eq, or lt so that operators and comparisons work on user-defined types with intuitive syntax and predictable semantics.

Related: dunder method, functools.total_ordering
functools.total_ordering

A class decorator that fills in the remaining rich comparison methods (le, gt, ge) once a class defines eq plus one of lt, le, gt, or ge.

Related: operator overloading
__call__

A dunder method that makes instances callable like functions. Defining it lets an object hold configuration state while still being invoked with parentheses.

Related: dunder method, closure
closure

A nested function that captures and retains variables from its enclosing scope after that scope has finished executing. Captured names are exposed through closure and read via nonlocal.

Related: nonlocal, __call__
nonlocal

A statement letting a nested function rebind a name from an enclosing function scope instead of creating a new local variable. It does not reach module or global scope.

Related: closure, global
class decorator

A callable applied to a class definition with the @ syntax that receives the class object and returns a replacement, often used to add methods or register classes in a registry.

Related: __init_subclass__, metaclass
PEP 8

The official style guide for Python code, covering naming conventions, indentation, imports, blank lines, and line length. Compliance is checked by linters such as flake8 or ruff.

Related: linter, docstring
PEP 257

The convention for docstrings: a one-line summary ending with a period, a blank line, then details for multi-line docstrings. It defines where docstrings belong and how tools read them.

Related: docstring, PEP 8
docstring

A string literal placed as the first statement of a module, class, or function, stored in doc. It documents intent and is extracted by help() and documentation generators.

Related: PEP 257, Sphinx
type hint

An annotation on a parameter, return value, or variable describing the expected type, such as list[int]. Hints are not enforced at runtime; static checkers and tools read them.

Related: mypy, typing.Optional
mypy

A static type checker that analyzes annotations without running the code, reporting incompatible assignments and calls. It supports gradual typing, so unannotated code is largely ignored.

Related: type hint, typing.Protocol
typing.Optional

A typing construct meaning a value is either the given type or None. Modern syntax writes it as X | None; it flags callers to handle the absent-value case.

Related: type hint, mypy
typing.Protocol

A base class for defining structural interfaces. A class satisfies a Protocol by having matching methods and attributes, without inheriting from it, enabling static duck typing.

Related: duck typing, abstract base class
duck typing

A style where an object's suitability depends on the methods and attributes it actually has, not on its declared type. Python resolves such behavior at runtime.

Related: typing.Protocol, EAFP
EAFP

Easier to Ask Forgiveness than Permission: a Python idiom of attempting an operation and handling the resulting exception, rather than pre-checking conditions as in LBYL style.

Related: try/except/else/finally, duck typing
try/except/else/finally

A compound statement where except handles matching exceptions, else runs only when no exception occurred, and finally always runs for cleanup. Order matters and bare except clauses hide bugs.

Related: EAFP, context manager
context manager

An object implementing enter and exit so it can be used in a with statement. It guarantees setup and teardown, such as closing files or releasing locks, even when exceptions occur.

Related: contextlib.contextmanager, try/except/else/finally
contextlib.contextmanager

A decorator turning a generator function into a context manager. Code before yield is setup, the yielded value becomes the as-target, and code after yield is teardown.

Related: context manager
linter

A tool that statically inspects source code for style violations, unused imports, and suspicious constructs without executing it. Common Python examples are ruff, flake8, and pylint.

Related: PEP 8, formatter
formatter

A tool that rewrites source code to a consistent layout automatically, such as black or ruff format. It removes debates over spacing while leaving semantics unchanged.

Related: linter, PEP 8
venv

The standard-library module for creating isolated environments with their own interpreter link and site-packages, so project dependencies do not clash across projects.

Related: pip, requirements.txt
requirements.txt

A plain-text file listing package specifications, optionally pinned with ==, that pip install -r reads to reproduce an environment. Pinning versions makes builds reproducible.

Related: venv, pip
tkinter

Python's bundled GUI toolkit wrapping Tcl/Tk. It provides widgets, geometry managers, and an event loop through mainloop(), requiring no third-party installation.

Related: geometry manager, event binding, mainloop
mainloop

The blocking call that starts a GUI application's event loop, dispatching user input and redraw events until the window closes. Code after it runs only after the loop exits.

Related: event binding, tkinter
geometry manager

A mechanism deciding widget size and placement inside a container. Tkinter offers pack, grid, and place; mixing pack and grid in one container causes layout errors.

Related: tkinter, event binding
event binding

Associating a callback with a user action, such as a click or keypress, using bind() or the command option. The callback runs later, inside the event loop.

Related: mainloop, callback
callback

A function passed to another component to be invoked later when something happens, such as a button press or a completed request. It should return quickly to avoid freezing the UI.

Related: event binding, mainloop
widget

A visible GUI component such as a button, label, entry, or frame. Widgets are arranged in a parent-child hierarchy and configured through options like text, width, and command.

Related: geometry manager, tkinter
REST

An architectural style for networked APIs using stateless requests, resource-oriented URLs, and standard HTTP methods. Representations are typically JSON, and servers should not rely on client session state.

Related: HTTP method, idempotent request, status code
HTTP method

The verb in a request indicating intent: GET retrieves, POST creates, PUT replaces, PATCH partially updates, and DELETE removes. Choosing the right method keeps APIs predictable.

Related: REST, idempotent request
idempotent request

A request that produces the same server state whether sent once or many times. GET, PUT, and DELETE are idempotent; POST usually is not, which matters for safe retries.

Related: HTTP method, retry with backoff
status code

A three-digit number in an HTTP response summarizing the outcome, such as 200 success, 201 created, 404 not found, or 500 server error. Clients branch on these values.

Related: REST, raise_for_status
requests.Session

An object that persists settings across requests, including headers, cookies, and connection pooling. Reusing one session speeds up repeated calls to the same host.

Related: requests library, timeout
requests library

A popular third-party HTTP client offering simple functions like get and post. Responses expose status_code, headers, text, and a json() method for parsing JSON bodies.

Related: requests.Session, raise_for_status
raise_for_status

A response method that raises an exception when the status code indicates a client or server error. It replaces manual status checks and surfaces failed calls immediately.

Related: status code, requests library
timeout

A limit on how long a client waits for a connection or response. Always setting it prevents a program from hanging indefinitely when a server stops responding.

Related: requests.Session, retry with backoff
JSON

A lightweight text data format of objects, arrays, strings, numbers, booleans, and null. Python maps it to dicts, lists, and primitives via the json module.

Related: deserialization, REST
deserialization

Converting a transferred representation such as JSON text into native objects. In Python, json.loads produces dicts and lists; the result should be validated before use.

Related: JSON, authentication token
authentication token

A credential string sent with requests, typically in an Authorization header, proving the caller's identity. Bearer tokens should be stored securely and never committed to source control.

Related: requests.Session, JSON
pagination

Splitting a large result set into pages using query parameters like limit and offset or a cursor. Clients must follow links or cursors until no further records remain.

Related: query parameter, REST
query parameter

A key-value pair appended to a URL after a question mark, used for filtering, sorting, or paging. The requests library accepts them as a params dictionary.

Related: pagination, REST
retry with backoff

Resending a failed request after increasing delays, often with jitter, to handle transient errors. It should be limited to idempotent operations or those with safe retry semantics.

Related: idempotent request, timeout