← Back to PyDebug

Python Glossary – Key Terms & Definitions

πŸ“– Python Terminology for Beginners

Variable
A name that stores a value. x = 5
Function
A reusable block of code defined with def. def add(a,b): return a+b
List
An ordered, mutable collection. fruits = ["apple", "banana"]
Tuple
An ordered, immutable collection. point = (3, 4)
Dictionary (dict)
Key‑value pairs. student = {"name": "Alice", "age": 25}
Set
Unordered collection of unique elements. unique = {1, 2, 3}
String (str)
Text data. "Hello"
Integer (int)
Whole numbers. 42
Float
Decimal numbers. 3.14
Boolean (bool)
True or False values.
Loop
Repeating code with for or while.
Conditional
if, elif, else statements.
Module
A file containing Python code, imported with import.
Exception
An error that disrupts normal flow; handled with try/except.
Indentation
Spaces or tabs at the beginning of a line to define code blocks.
Immutable
Cannot be changed after creation (e.g., strings, tuples).
Mutable
Can be changed (e.g., lists, dictionaries).
PEP 8
Python's style guide for writing readable code.

🧠 Intermediate Vocabulary

These are the terms that appear once you move past scripts and start reading real Python code, error messages, and interview questions. Each definition includes the gotcha it is famous for.

Parameter vs. Argument
The parameter is the name in the definition (def f(x)); the argument is the value passed in (f(3)). Mixed up constantly, separated in every serious discussion.
Return value
What a function hands back via return. A function with no return gives back None β€” the source of countless TypeError: unsupported operand type(s) … 'NoneType' bugs.
Scope (LEGB)
Where a name is looked up: Local β†’ Enclosing (outer functions) β†’ Global (module) β†’ Built‑in. If you assign a name anywhere in a function, that name is local everywhere in it β€” otherwise you get UnboundLocalError.
None
Python's singleton for "no value". Test it with is None / is not None, never == False β€” and remember None is falsy, which is why "missing" values vanish silently in if x: checks.
Truthy / Falsy
Values that count as True or False in a condition. Falsy: False, 0, 0.0, "", [], {}, set(), None. Everything else β€” including "0" and [0] β€” is truthy.
Slice
A subsequence produced by seq[start:stop:step] that excludes stop and never raises for out-of-range bounds. "python"[1:3] is "yt"; "python"[10:] is "".
f-string
A string literal prefixed with f that interpolates expressions: f"{name} is {age + 1}". Forgetting the f prints the braces literally β€” a classic PyDebug bug-fix problem.
Iterable
Anything a for loop can walk over: lists, strings, dicts (their keys), file handles, generators. "Not iterable" errors usually mean you tried to loop over an int or None.
Iterator
The object an iterable produces that yields items one at a time via next(), raising StopIteration at the end. An iterator can be consumed once; the iterable can be iterated again.
Comprehension
A compact way to build a list/dict/set from an iterable: [n * 2 for n in nums if n > 0]. Readable in simple cases, cryptic when nested more than two levels.
Generator
A function using yield that produces values lazily. Memory-efficient for big sequences, but one-shot: iterate it twice and the second pass is empty.
Unpacking
Assigning elements in one shot: a, b = b, a swaps without a temp. Raises ValueError whenever the count on the left doesn't match the iterable on the right.
Mutable default argument
A default list/dict in a signature is created once, at definition, and shared by every call: def add(x, bucket=[]) accumulates forever. The standard fix is a None default plus if bucket is None.
Recursion / base case
A function that calls itself; the base case is the input where it answers directly and stops. Missing base cases don't hang β€” Python raises RecursionError past ~1000 frames.
Traceback
The error report printed on a crash: call chain plus final exception. Read it bottom-up β€” the last line is the verdict, the frames above are the journey.
breakpoint() / pdb
Stops execution so you can inspect live state; pdb commands n/s/c/p step, descend, continue, print. The grown-up version of print-debugging.
Decorator
A function that wraps another function, written as @name above a definition. Used for logging, timing, caching, and route registration (as in Flask).
Lambda
A one-expression anonymous function: sorted(words, key=lambda w: len(w)). If a lambda needs statements or two lines, promote it to a real def.
Docstring
The string literal on the first line of a module, class, or function; readable at runtime via help() or __doc__. Documentation that ships inside the code.
Module vs. Package
A module is one .py file; a package is a directory of modules (with __init__.py). Both are accessed with import.
Standard library
The modules that ship with Python β€” math, random, json, datetime, os β€” so "batteries included" means most plumbing needs no pip install.
Virtual environment
An isolated folder of packages per project (python -m venv .venv), so two projects can pin different versions of the same library without a knife fight.
Call stack
The list of function calls currently in progress, newest on top. Tracebacks are read against it, and RecursionError means it grew too deep.
Immutability
An object whose contents cannot be changed after creation (str, tuple, int, frozenset). "Immutable" β‰  "reassignable": t = t + (4,) builds a new tuple, it doesn't grow the old one.
Zen of Python (PEP 20)
import this prints it: "Readability counts", "Simple is better than complex", "Errors should never pass silently" β€” the cultural north star behind every style rule on this list.

πŸ“š Using This Glossary Well

Definitions are only the first ten percent of a term β€” the other ninety is having seen it misbehave. For every term that was new or fuzzy here, spend five minutes in the Playground triggering exactly that confusion once (loop over an int, iterate a generator twice, mix = and ==), then cement it with a targeted problem set: functions for scope and returns, loops for iteration, dictionaries for keys and .get(). The errors guide explains the crash messages these terms cause, and the tutorials page sequences the same ideas into a learning path.