Python Bites: Glossary

Python keywords and terms

Generated with ChatGPT 4o
Term Definition
Abstract Base ClassA class using abc.ABC that defines interface contracts with abstract methods subclasses must implement.
ArgumentA value passed to a function when it is called.
Async/AwaitKeywords enabling cooperative multitasking: async def defines a coroutine, await suspends it until a result is ready.
BytecodeCompiled intermediate representation of Python source executed by the CPython virtual machine.
ClassA blueprint for creating user-defined objects with attributes and methods.
ClosureA function that captures and retains variables from its enclosing lexical scope after that scope has exited.
ComprehensionConcise syntax for creating sequences, e.g., list comprehensions: [x for x in range(5)].
Context ManagerAn object implementing __enter__ and __exit__ that manages resource setup and teardown via the with statement.
CoroutineA function defined with async def that can suspend execution at await points and resume later.
CPythonThe reference implementation of Python, written in C, that compiles source to bytecode and executes it in a virtual machine.
DecoratorA function that modifies the behavior of another function or method using @ syntax.
DeepcopyA copy operation (copy.deepcopy) that recursively duplicates an object and all objects it references.
DescriptorAn object with __get__, __set__, or __delete__ methods that intercepts attribute access on class instances.
DictionaryA collection of key-value pairs: {'key': 'value'}.
Duck TypingA typing strategy where an object's suitability is determined by its methods and properties rather than its explicit type.
Dunder MethodsSpecial methods with double-underscore names (e.g., __init__, __repr__) that Python calls implicitly for operator and protocol support.
ExceptionAn error detected during execution that can be handled with try/except.
F-StringA string literal prefixed with f that evaluates embedded expressions at runtime: f"{name} is {age}".
FunctionA block of reusable code defined using the def keyword.
GeneratorA function that uses yield to produce a sequence of values lazily.
Generator ExpressionA lazy iterator created with parenthesis syntax: (x*x for x in range(10)).
Global Interpreter LockA mutex in CPython that allows only one thread to execute Python bytecode at a time, limiting CPU-bound parallelism.
ImmutableDescribes types that cannot be changed after creation (e.g., tuple, str, int).
ImportStatement used to bring modules and their functions into the current namespace.
IndentationWhitespace that defines block structure in Python code. It replaces curly braces used in other languages.
IterableAny object capable of returning its elements one at a time, e.g., lists, strings, files.
IteratorAn object representing a stream of data that implements the __next__() method.
LambdaAn anonymous function defined with the lambda keyword.
ListAn ordered, mutable sequence of items: [1, 2, 3].
MetaclassThe class of a class; customizes class creation behavior, with type as the default metaclass.
Method Resolution OrderThe linearized sequence of classes Python searches when resolving method or attribute lookups in an inheritance hierarchy.
MixinA class providing reusable methods via multiple inheritance without being intended as a standalone base type.
ModuleA file containing Python definitions and statements, typically ending in .py.
NonlocalA keyword that allows an inner function to rebind a variable from an enclosing (non-global) scope.
ObjectAn instance of a class. Almost everything in Python is an object.
PackageA directory containing an __init__.py file and one or more modules.
ParameterA variable in a function definition that accepts a value when the function is called.
PipThe standard package installer for Python, used to install and manage packages from PyPI.
ProtocolA structural typing mechanism (from typing) that defines an interface by required methods and attributes without inheritance.
Reference CountingCPython's primary memory management technique; objects are freed when their reference count drops to zero.
SetAn unordered collection of unique elements: {1, 2, 3}.
SliceA way to extract parts of sequences using [start:stop:step] syntax.
StringA sequence of Unicode characters: "hello" or 'hello'.
Structural Pattern MatchingPython 3.10+ feature using match/case to destructure and branch on the shape of data.
TupleAn immutable sequence of elements: (1, 2, 3).
Type HintsOptional annotations on variables and function signatures indicating expected types, used by static analyzers but not enforced at runtime.
TypeVarA placeholder type variable from the typing module used to define generic functions and classes.
VariableA name that refers to a value stored in memory.
Virtual EnvironmentAn isolated Python environment for managing dependencies separately from the global installation.
Walrus OperatorThe := operator (Python 3.8+) that assigns a value within an expression.
YieldA keyword used in generator functions to return a value and suspend function state.