Chapter 09: Lecture Notes
Big Picture:
- Not every traditional control structure can be replaced by these shorthand syntaxes, only the most common use cases. (But those are common enough to make these quite valuable.)
- There is no requirement that a programmer uses these syntaxes. It certainly is possible to accomplish any of these tasks with more traditional means. However:
- These are incredibly useful if you want to be a "Python Wizard"
- If used appropriately, they can make the code much easier to read/understand
- These tend to execute much more efficiently than their traditional versions (because Python implementers have optimized in ways that aren't possible for the more general purpose of loops and conditionals)
- We are taking a few days to introduce them, both because they are useful but also because they give us yet more chance to reinforce recent lessons about the use of for loops and conditionals.
Michael Goldwasser
Last modified: Sunday, 22 December 2019