Everyone knows how an if-else block works, but what about a for-else block? Or try-except-else? What do those do, and how can they help us write cleaner code? What other hidden gems await us in the halls of Python grammar? Come join us for an adventure into depths of the Python world less traveled.
We'll start with a brief look at the fundamentals of program control flow, and how our choices as developers influence the readability and maintainability of our code. We'll look at some easy ways to use lesser-known syntax elements to make common code patterns more obvious, and compare and contrast them with equivalent alternatives.
Next, we'll start to pull back the curtains a bit on how Python handles more complex control flow mechanisms, like generators and decorators, and look at ways to leverage those features to build higher order functionality. Lastly, we'll get a bit reckless and look at how Python makes it possible to create our own systems for control flow, and consider committing some light crimes in the name of code readability.
We might even implement the highly desired "do-while" loop while we're at it.