Best Practices
Docstrings
()
Docstrings to the rescue!
DRY and "Do One Thing"
()
Extract a function
Pass by assignment
()
Best practice for default arguments
Context Managers
Using context managers
()
The number of cats
The speed of cats
Writing context managers
()
The timer() context manager
A read-only open() context manager
Advanced topics
()
Scraping the NASDAQ
Changing the working directory
Decorators
Functions are objects
()
Building a command line data app
Returning functions for a math game
Scope
()
Closures
()
Decorators
()
Defining a decorator
More on Decorators
Real-world examples
()
Print the return type
Counter
Decorators and metadata
()
Measuring decorator overhead
Decorators that take arguments
()
Timeout(): a real world example
()
Tag your functions
Great job!
()