Skip to content

Python Beyond the Basics

Glossary

118 terms from Python Beyond the Basics, in plain words, each with the chapter that teaches it.

#

!r
An f-string marker that shows a value the way you would type it in code, so text keeps its quotes. For example, `GiftCard('Ada', 30)` shows `'Ada'` in quotes.
*args and **kwargs
A `*` before a parameter collects extra arguments into a tuple, and `**` collects extra keyword arguments into a dict. A `*` before a list when calling spreads it out into separate arguments.
__eq__ / __lt__
Special methods that define what `==` and `<` mean for your own objects. Python also uses `__lt__` when sorting, so a Product with `__lt__` can be sorted by price.
__init__
A special method Python runs automatically when a new object is created. It sets up the object's starting attributes, such as a GiftCard's owner and balance.
__init__.py
A file placed in a folder to mark it as a package, such as `payments/`. It can be empty.
__name__ guard
An `if __name__ == "__main__":` check that runs code only when a file is run directly, not when another file imports it. It stops test lines in pricing.py from running on import, and usually calls `main()`.
__repr__
A special method that returns the text Python shows when you print an object. Without it you see something like `<__main__.GiftCard object at 0x10a3f2b50>`.

A

activate (virtual environment)
The command that tells your current terminal to use a virtual environment's packages. You need to do it again in each new terminal, and `deactivate` switches it off.
API (application programming interface)
A service built for programs, not people, to request data from, usually answering in JSON. Exchange rates, weather and maps are available this way.
API key
A secret code that identifies you to an online service. Treat it like a password: keep it in an environment variable, never in your code.
argparse
A standard-library module that reads command-line arguments, checks them, and writes help text and error messages automatically. The expense tracker uses it to define its `add`, `list` and `summary` commands.
assert
A keyword that checks something is true; if it isn't, Python raises an AssertionError. Tests are built from `assert` lines.
async / await
Python's built-in way to do concurrency. `async def` makes a function that can pause, and `await` marks where it pauses to wait so other code can run.
asyncio
The standard-library module that runs async code. `asyncio.gather` runs several coroutines together and `asyncio.run` starts the whole program.
attribute
A value stored on an object, such as `self.balance` on a gift card. In a dataclass the attributes are called fields.
automatic test
A small piece of code that checks another piece of code and reports whether it still works. A whole set of tests can run in a second, as often as you like.

B

basicConfig
The function that sets up logging: the lowest level to show, the line format, and optionally a file to write to. It only takes effect the first time it's called in a program.
breakpoint
A pause point in a running program. `breakpoint()` stops it at a `(Pdb)` prompt where you can inspect variables, and VS Code's red dot does the same visually.
byte
The unit computers measure storage in. One byte holds roughly one character of plain text, and `.stat().st_size` gives a file's size in bytes.

C

cents storage (whole-number money)
Storing money as a whole number of cents in an INTEGER column, because SQLite's REAL columns hold inexact floats. `Decimal("12.50")` is saved as 1250 and converted back when read.
child class / parent class
In inheritance, the parent is the original class and the child is the new class built on it. PromoCard is a child of GiftCard and gets all its methods.
class
A blueprint for making your own type of object, bundling data and the methods that work on it. GiftCard is a class describing every gift card in the shop.
command-line arguments
The words typed after a program's name in the terminal, such as `add 12.50 postage`. Programs read them to know what to do.
commit
To save a database's changes permanently. `with connection:` commits at the end of the block, and cancels everything if an error happens.
concurrency
Letting a program start the next task while earlier ones are still waiting. It speeds up programs that mostly wait for websites, files or databases.
concurrent.futures
The module providing thread pools and process pools. `ThreadPoolExecutor.map` runs a function on many items at once, and `ProcessPoolExecutor` does the same in separate copies of Python.
context manager
An object that works with `with`, setting something up at the start and cleaning up at the end, like `open` closing a file. You can write one with the `@contextmanager` decorator around a generator that has one `yield`.
core
One of the independent calculating units inside a CPU; most computers have several. `ProcessPoolExecutor` uses one process per core.
coroutine
A function defined with `async def` that can pause while it waits, letting other code run. Calling one doesn't run it until it is awaited or passed to `gather`.
Counter
A tool from `collections` that counts how often each item appears. A missing item counts as 0 instead of raising KeyError, and `most_common(n)` returns the top n.
CPU (central processing unit)
The computer's main chip, which does the calculating. A program is CPU-bound when this chip is busy the whole time.
CPU-bound
Work where the computer is busy calculating the whole time, rather than waiting. Threads don't help; use `ProcessPoolExecutor` instead.
CSV (comma-separated values)
A plain-text table with one row per line and commas between values; the first line is usually the header of column names. The `csv` module's DictReader and DictWriter read and write rows as dicts.

D

dataclass
A class whose `__init__`, `__repr__` and `__eq__` are written for you by the `@dataclass` decorator from a list of typed fields. Options like `order=True` and `frozen=True` add sorting and immutability.
datetime / timedelta
`datetime` holds a date and a time, and `timedelta` is a length of time. Adding a timedelta moves a date forward, and subtracting two dates gives one.
Decimal
A number type for exact decimal arithmetic, used for money so amounts add up with no tiny float errors. `.quantize(CENT)` rounds to two decimal places.
decorator
A function that takes a function and returns an improved version of it, applied with `@` above a `def`. `@logged` above `add_tax` means `add_tax = logged(add_tax)`.
deepcopy
A function from the `copy` module that copies every level of nested data, so lists inside lists are not shared with the original.
defaultdict
A dict that creates a starting value automatically the first time you use a missing key. `defaultdict(list)` makes grouping easy, such as grouping products by customer.
docstring
A text string placed first inside a function, class or file to describe it. It is also enough to fill an otherwise empty class.

E

environment variable
A named setting kept by the terminal, read in Python with `os.environ.get()`. It's the safe place to keep an API key, set with `export NAME=value` on macOS/Linux.
exception
An error object. You create your own kind with a class that inherits from `Exception`, like OutOfStockError, and `raise` it when something goes wrong.

F

f-string debug specifier (=)
Writing `=` after a name inside an f-string's braces prints the code and its value, such as `total=42`. A quick way to inspect values.
f-string format specifiers
Codes after a colon inside an f-string's braces that control layout: `:.2f` gives two decimal places, `:<12` and `:>8` pad left or right, `05d` pads with zeros, and `.0%` shows a percentage.
fetchall / executemany
`fetchall()` returns all rows from a query as a list of tuples. `executemany` runs one SQL command once for each tuple in a list.
fixture
A helper that pytest passes to a test when the test names it as a parameter. `tmp_path` gives each test a fresh temporary folder, and you can write your own with `@pytest.fixture`.
format codes (dates)
Short codes like `%Y` (year) and `%H` (hour) used to describe a date's layout. `strftime` turns a datetime into text and `strptime` reads text into a datetime.
frozen dataclass
A dataclass whose instances can't be changed after creation; assigning to a field raises FrozenInstanceError. Good for values like an Expense that shouldn't change once recorded.

G

generator
A function that uses `yield` to produce values one at a time, pausing between them. It can handle huge or endless data and can be used only once.
generator expression
A comprehension in parentheses that produces values one at a time instead of building a list, such as `sum(price * 1.2 for price in prices)`.
Git
Git records every change you make to a project so you can see what changed and undo mistakes. GitHub stores Git projects online to back them up and share them.
glob / rglob
Path methods that list files whose names match a pattern, where `*` means anything. `rglob` also searches inside all folders below.
global
A Python keyword placed inside a function that tells Python a name refers to a variable defined outside the function, so assigning to it changes that outer variable instead of creating a local one. It is usually better avoided, because functions that quietly change outside variables are hard to understand and test; passing values in and returning the new one is clearer.

H

HTTP status codes
A number in a server's response saying how the request went: 200 means OK, 404 means not found, other 400s mean the request itself was wrong, and 500s mean the server had a problem.
httpx
A third-party package that works like `requests` and also has an async version, suited to async code.

I

I/O-bound
Work that mostly waits on input and output such as networks, files or databases. Threads or async speed it up a lot.
inheritance
Building a child class on top of a parent class so it gets all the parent's methods and can add or change some. PromoCard inherits from GiftCard.
instance
One object made from a class. Calling `GiftCard("Ada")` creates an instance of GiftCard.
is vs ==
`==` asks whether two values have the same contents, while `is` asks whether they are the very same object. Use `is` mainly to check for `None`.
isinstance
A built-in function that checks whether an object is an instance of a class, including parent classes. `isinstance(promo, GiftCard)` is True.
iterable / iterator
An iterable is anything a `for` loop can walk through; an iterator is the object that remembers its place and hands out items with `next`. When items run out, `next` raises StopIteration, which the loop catches to stop.

J

JSON (JavaScript Object Notation)
A text format for structured data that looks like Python dicts and lists, used by programs and websites to exchange data. The `json` module's `dump`/`load` work with files and `dumps`/`loads` with strings.

K

key function
A function passed as `key=` to `sorted`, `min` or `max` that Python calls on each item to decide what to compare. Pass the function's name without parentheses.
keyword argument
An argument passed as `name=value`, such as `timeout=10`. A function can collect extra ones into a dict with `**kwargs`.

L

lambda
A small, nameless, one-line function holding a single expression, such as `lambda order: order[1]`. Handy as a sort key.
LIKE
A SQL comparison that matches text against a pattern in which `%` means anything. `2026-10%` matches every day in October 2026.
list comprehension
A one-line way to build a list, dict or set from another collection, such as `[price * 1.2 for price in prices]`. A trailing `if` filters; `A if cond else B` at the front picks a value per item.
logging
A standard-library module for recording what a program does, with levels (debug, info, warning, error) you can filter and send to a file. `logging.exception` records a message plus the full traceback.

M

method
A function defined inside a class, whose first parameter is `self`. Python passes the object in automatically when you call it.
module
A Python file whose code you can bring into another file with `import`. Importing runs the whole file.
monkeypatch
A pytest fixture that temporarily replaces something for one test, such as swapping `requests.get` for a fake so a test doesn't need the internet.
mutable / immutable
Mutable values (lists, dicts, sets) can be changed in place; immutable ones (numbers, strings, tuples) can't, so operations on them make a new value. Sharing a mutable object between names can cause surprises.
mutable default trap
A bug where a list or dict used as a default parameter value is created once and shared by every call. Fix it by defaulting to `None` and creating a fresh list inside the function.
mypy
A tool that checks a whole project for type mistakes using its type hints, before the code runs.

N

Next-step tools (pandas, matplotlib, FastAPI, openpyxl and more)
Packages the last chapter suggests next: pandas, matplotlib and Jupyter for data and charts; FastAPI or Django for websites; openpyxl for Excel files; numpy and scikit-learn for AI work.
NotImplemented
A value a special method like `__eq__` returns to tell Python the class can't compare with that kind of object, so `==` gives False instead of an error.

O

object
A value living in the computer's memory. A variable is just a name pointing at an object, and two names can point at the same one.
option
A command-line argument starting with `--` that the user may leave out, in which case its default is used, like `--day`.

P

package
A folder of modules with an `__init__.py`, imported with a dot. The word also means code you install with pip; third-party packages are written by other people, not part of Python.
parametrize
A pytest decorator that runs one test several times, once for each value in a list, such as four bad amounts passed to `money()`.
parser
The object `build_parser()` returns that reads the command line. `parse_args` returns an object holding each argument as an attribute, and stops with an error if the command line is wrong.
pathlib
A module whose `Path` objects handle file and folder addresses correctly on every system; `/` joins pieces and methods like `read_text`, `mkdir` and `glob` work with files.
PEP 8
Python's official style guide. Tools like ruff can apply it for you.
pip
The installer that comes with Python, used to install packages from PyPI. `pip freeze` lists installed packages and versions.
placeholder
A `?` in a SQL command that is filled in, in order, from a tuple passed separately. It keeps values apart from the SQL and prevents SQL injection.
positional argument
A command-line argument that must always be given, in a fixed position, such as `amount` and `category` in `add 12.50 postage`.
primary key
A column that gives every row a unique value; `id INTEGER PRIMARY KEY` is filled in automatically with a new number for each row.
property
A decorator that lets a method be read like an attribute, without parentheses. It's calculated each time, so it never goes out of date.
PyPI (Python Package Index)
The online collection of packages written by other people, at pypi.org, which pip installs from.
pytest
The most popular tool for running automatic tests; it runs every `test_` function in every `test_` file. `pytest.raises` checks an error is raised, and `pytest.approx` compares floats allowing a tiny difference.

R

raise (bare / re-raise)
Using `raise` alone inside an `except` block passes the same error on after you've done something like logging it.
raw string
A string written with `r` before the quote, in which Python leaves backslashes alone. Regular expression patterns are written this way, like `r"\d+"`.
README.md
A file explaining what a project does and how to run it; GitHub shows it on the project's front page.
regular expression
A pattern for finding text that follows a shape, such as "ORD- plus four digits", used with the `re` module. `findall` returns every match, `sub` replaces, `search` finds the first, and parentheses mark groups to pull out.
request / response
A program or browser sends a request to a server at a URL, and the server sends back a response with data and a status code.
requests
A popular third-party package for talking to websites. `requests.get(url, params=..., timeout=...)` fetches data, `.json()` converts it, `raise_for_status()` turns bad status codes into errors, and `RequestException` covers network problems.
requirements.txt
A file listing a project's packages and versions, made with `pip freeze > requirements.txt`. Share it instead of the `.venv` folder so others can rebuild the setup.
ruff
A tool that tidies the layout of your code (`ruff format .`) and points out likely mistakes (`ruff check .`).

S

self
The first parameter of a method: the object the method is working on. Python passes it in for you when you call `card.top_up(50)`.
shallow copy
A copy of the outer list or dict only, so mutable items inside it are still shared with the original. `.copy()`, `list(x)` and `x[:]` make shallow copies.
special method
A method with two underscores at each end, like `__init__` or `__repr__`, that Python calls automatically to hook your objects into printing, comparing and sorting.
SQL (Structured Query Language)
The language used to talk to databases, built from commands such as `CREATE`, `INSERT` and `SELECT`. `WHERE` filters rows, `ORDER BY` sorts them, and `SUM` with `GROUP BY` totals per group.
SQL injection
An attack where a user types text that changes the meaning of your SQL, for example to delete a table. Avoid it by using `?` placeholders, never f-strings, for values.
SQLite
A small database that keeps everything in one ordinary file, used through Python's built-in `sqlite3` module. Data lives in tables, where each row is one record and each column has a name and type.
standard library
The large set of modules that come built in with Python, such as `random`, `csv` and `sqlite3`. Anything else is a third-party package you install with pip.
super()
A function that reaches the parent class, so `super().__init__(...)` runs the parent's setup instead of repeating it.

T

thread
A separate line of work inside a program; while one thread waits, another can run. Threads share variables, so have each job return its result rather than changing shared lists.
time.perf_counter
A precise clock; subtracting two readings measures how long something took. `time.sleep` pauses to pretend to wait for a slow website.
traceback
The report Python prints when an error stops a program, showing where it happened. `logging.exception` records one in a log.
try / except / else / finally
`except` handles an error, `else` runs only if the `try` raised no error, and `finally` runs no matter what, making it the place for clean-up.
type hint
A note of what type a value should be, such as `price: float` or `-> float | None`. Python ignores hints when running, but people and tools like VS Code and mypy use them.

U

UnboundLocalError
The error raised when a function assigns to a name (like `+=`), making it local, but reads it before it has a value.
UTF-8 / encoding
The text encoding that handles accents and symbols; passing `encoding="utf-8"` when reading or writing files avoids garbled characters.

V

virtual environment
A private folder of installed packages for one project, so upgrading a package in one project can't break another. Create with `python3 -m venv .venv` and activate it.
VS Code debugger
A visual debugger in VS Code: click left of a line number to set a breakpoint, press F5, and the sidebar shows every variable's value as you step through.

W

wraps
A decorator used inside your own decorator that copies the original function's name and docstring onto the wrapper, so the decorated function still describes itself.

Z

zip
A function that walks through two or more lists together, giving one item from each per pass. `strict=True` raises an error if the lists differ in length instead of quietly cutting the longer one.
ZoneInfo
A class from the `zoneinfo` module that attaches a time zone, such as "America/Los_Angeles", to a datetime. Windows needs `pip install tzdata` first.