Reference · living document

Python Glossary

Canonical definitions used across every lesson in this workspace.

Running code

REPL
Read-Eval-Print Loop — the interactive python3 shell. Evaluates one line at a time, prints results back. Good for quick checks, not for real scripts.
script
A .py file run top-to-bottom with python3 file.py.

Syntax

indentation block
Python's block syntax: a header line ending in : (after if, for, def, etc.), followed by consistently-indented lines. No braces — the whitespace itself delimits the block.
dynamic typing
A name is bound to a value, not declared with a fixed type. The same name can be rebound to a value of a different type later — legal, though usually a sign of confused code.
snake_case
Python's naming convention for variables and functions: lowercase words joined by underscores. Defined in PEP 8, followed by virtually every library, including pandas.
f-string
A string literal prefixed f, e.g. f"{name} is {age}" — expressions inside { } are evaluated and interpolated inline. The standard way to build strings with embedded values.

Data Structures

list
Ordered, mutable sequence. Created with square brackets: [1, 2, 3]. Zero-indexed. The most common container — pandas Series is essentially a labeled list.
dict (dictionary)
Key-value mapping. Created with braces: {"key": value}. Keys must be hashable (strings, numbers, tuples). Insertion-ordered since Python 3.7. A DataFrame row is conceptually a dict.
tuple
Immutable sequence. Created with parentheses (or just commas): (1, 2) or 1, 2. Can't be changed after creation. Used for dict keys, function return values, and DataFrame index entries.
indexing
Accessing an element by position: items[0] (first), items[-1] (last). Works on lists, tuples, and strings. Zero-based.
slicing
Extracting a sub-sequence: items[start:stop]. The stop index is excluded. Omit start or stop to go from the beginning or to the end.
list comprehension
One-line syntax to build a new list by transforming another: [expr for x in iterable]. Optionally filtered: [expr for x in iterable if cond]. The idiomatic Python replacement for map/filter patterns.
unpacking
Binding multiple names in one statement by matching a sequence's shape: x, y = (3, 5). Works with any iterable of the right length.
mutable vs immutable
Lists and dicts can be changed in place (mutable). Tuples and strings cannot (immutable). Matters for: dict keys (must be immutable) and shared references.

Strings & Files

string slicing
Strings index and slice like lists (s[0], s[1:3]) since a string is a sequence of characters — just an immutable one.
context manager
An object usable with with obj as name: that guarantees setup/cleanup around the block — most commonly with open(path) as f:, which closes the file automatically even if an exception occurs inside.
csv.DictReader
Standard-library CSV parser (import csv) that reads each row as a dict keyed by the header row, and correctly handles quoted fields containing commas — unlike hand-rolled line.split(","). All values come back as strings; you convert types yourself.