β 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
fororwhile. - Conditional
if,elif,elsestatements.- 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 noreturngives backNoneβ the source of countlessTypeError: 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 rememberNoneis falsy, which is why "missing" values vanish silently inif 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 excludesstopand never raises for out-of-range bounds."python"[1:3]is"yt";"python"[10:]is"". - f-string
- A string literal prefixed with
fthat interpolates expressions:f"{name} is {age + 1}". Forgetting thefprints the braces literally β a classic PyDebug bug-fix problem. - Iterable
- Anything a
forloop can walk over: lists, strings, dicts (their keys), file handles, generators. "Not iterable" errors usually mean you tried to loop over anintorNone. - Iterator
- The object an iterable produces that yields items one at a time via
next(), raisingStopIterationat 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
yieldthat 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, aswaps without a temp. RaisesValueErrorwhenever 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 aNonedefault plusif 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
RecursionErrorpast ~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;
pdbcommandsn/s/c/pstep, descend, continue, print. The grown-up version of print-debugging. - Decorator
- A function that wraps another function, written as
@nameabove 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 realdef. - 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
.pyfile; a package is a directory of modules (with__init__.py). Both are accessed withimport. - 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
RecursionErrormeans 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 thisprints 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.