References#
ποΈ Lecture 4
ENPM605 β L4: Function Fundamentals
Covers function definition and calling, arguments (positional, default, keyword, *args, **kwargs), scopes and the LEGB rule, pass-by-assignment, type hints (Optional, Union, pipe syntax), Google-style docstrings, and recursion.
π Python Language References
Tutorial β Control Flow
Function definition, parameters, return values, and default arguments.
Tutorial β Control Flow
Advanced argument handling, *args, **kwargs, and unpacking.
Tutorial β Classes
Pythonβs scope rules, the LEGB lookup order, and namespace mechanics.
Standard Library β typing
Type hints, Optional, Union, and generic types.
Python FAQ
Explanation of how Python passes arguments and why it is neither pass-by-value nor pass-by-reference.
Tutorial β Control Flow
Recursive function examples and the Fibonacci sequence.
Tutorial β Control Flow
How to use function annotations for parameter and return type hints.
PEP 257
Docstring conventions for modules, functions, classes, and methods.
π Style and Best Practices
Coding Conventions
Guidelines for function naming, parameter formatting, and documentation.
Type Hints
The PEP that introduced type hints to Python.
Simplified Union Syntax
The PEP that introduced X | Y syntax as an alternative to Union[X, Y] in Python 3.10+.
Docstrings Section
Googleβs conventions for writing docstrings, including Args, Returns, and Raises sections.
π Recommended Reading
Getting Started
Section 4.7 (Defining Functions) and Section 4.8 (More on Defining Functions) cover this lectureβs topics.
Learning Python (5th Edition)
Chapters 16-21 cover function basics, scopes, arguments, and advanced function topics in depth.
Fluent Python (2nd Edition)
Chapters 7-9 cover first-class functions, type hints, decorators, and closures. Excellent for understanding functions as objects.
Effective Python (2nd Edition)
Items 19-26 cover function arguments, return values, closures, and decorators with practical best practices.