Program architecture
Separating computation from input and output lets a program rule be tested without opening files.
CKTIS / Python
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Separating computation from input and output lets a program rule be tested without opening files.
An event loop interleaves tasks when the running coroutine suspends while waiting for a result.
Choose a sequence for indexed positions, a set for unique hashable members and a dictionary for key-to-value lookup.
A # outside a string literal begins a comment that continues to the end of the physical line.
Build a list, set or dictionary by nesting iteration clauses in written order and applying filters before the output expression.
An if statement tests its conditions in order and executes the first truthy branch.
A with statement binds the result of `__enter__` to its as target and invokes `__exit__` when leaving the block.
Connect a source, lazy parsing and selection stages, and a terminal operation that drives consumption.
Decorator expressions are evaluated at definition time from top to bottom and applied from bottom to top.
An exception interrupts normal evaluation and searches outward for the first matching except clause.
Operator precedence determines expression grouping, and parentheses can override it.
Filtering keeps original values whose predicate is true, while mapping emits the transformed value for every input it receives.
The current state and event form a key that selects the next state in a finite transition table.
For an ordinary undecorated function, def binds its name to the function and a call executes its body. A generator function call creates a generator, and a decorator can bind the name to another object.
Separate the stream’s bytes, their character encoding and the format parsed from the resulting text.
An iterable can supply an iterator, whose next operation advances state and signals exhaustion with StopIteration.
Inspect values in encounter order until the first equality match.
A logger decides whether to accept an event at its severity and a handler chooses the output destination and threshold.
A for loop consumes an iterator, while a while loop retests its condition before every iteration.
Assignment binds another name to an existing object without copying it.
A module owns a namespace, and an import binds a name in the importing code.
Select an integer, binary float, decimal or rational representation to match the calculation.
An object can hold another object in an instance attribute and delegate work to it.
Count the work that grows with input size and distinguish it from machine-dependent elapsed time.