Skip to main content

29 docs tagged with "functions"

View all tags

*args and **kwargs - Variable-Length Arguments in Python

Master Python's *args and **kwargs at engineering depth - how packing and unpacking work at the bytecode level, all 5 parameter types in order, forwarding patterns, decorator argument passing, and the anti-patterns that signal poor API design.

Closures - Functions That Remember Their Environment

Master Python closures at engineering depth - how inner functions capture free variables in cell objects, the classic loop-variable bug, nonlocal, function factories, closures as lightweight classes, and real-world patterns like memoization and event handler factories.

Higher-Order Functions - Functions as First-Class Citizens

Master Python higher-order functions at engineering depth - map, filter, reduce, functools.partial, lru_cache, function composition, and building your own pipelines. Learn when to use functional patterns and when to prefer comprehensions.

Recursion Fundamentals - Thinking in Self-Reference

Master Python recursion at engineering depth - base cases, recursive reduction, call stack mechanics, Python's recursion limit, classic algorithms, the dramatic performance difference between naive and memoized Fibonacci, and when recursion is the right tool.

Return Semantics - What Python Functions Actually Return

Master Python return semantics at engineering depth - how the RETURN_VALUE opcode works, why multiple return values are actually tuples, guard clauses, type-consistent returns, factory functions, and the Result pattern for error handling without exceptions.

Scope and LEGB - How Python Resolves Names

Master Python's scope resolution at engineering depth - the LEGB rule, how the compiler decides LOAD_FAST vs LOAD_GLOBAL at compile time, global and nonlocal keywords, and common scope bugs.