Return values from Python functions, understand local scope, chain functions into pipelines, and document each function's contract with docstrings.
Overview
Syllabus
- Unit 1: Returning Values in Python
- Reading a Returned Value
- From Printing to Returning
- Using Returned Values Inline
- Reusing Values and Meeting None
- Repairing a Missing Return
- Unit 2: Understanding Function Scope
- Where rate Lives
- Returning a Local Instead of Reaching
- Same Name Different Scope
- Building compute_tax with a local rate
- Using a Local Intermediate
- Unit 3: Chaining Functions Together
- Following a Value Through Three Functions
- Chaining Calls in One Expression
- Inserting a Stage Into the Pipeline
- Combining Returns and Naming Stages
- Building the Final Receipt Pipeline
- Unit 4: Writing Function Contracts
- Reading a Function's Contract
- Documenting an Undocumented Function
- Reading Documentation Back at Runtime
- Repairing a Stale Contract
- Writing a Documented Function