Learning the ropes: understanding Python generics
- 30 minutes
What if you don't want a Cat to be an Animal? What is the Liskov Substitution Principle? And what on earth is contravariance?
Discover the answers to these questions and more, as we explore the foundations of generic types in Python. And by the end, you might even understand the weirder errors that Mypy sometimes throws your way.
Do you run a static type checker, such as Mypy, on your Python code? And have you ever been confused by the error messages?
In Learning the Ropes, we'll explore how the Python's support for generics can unlock new patterns in your code. Along the way, we'll learn about some foundations of type theory which will give you a firmer understanding of what type safety really means. Suddenly those Mypy errors will make sense. Be prepared to think hard and learn fancy new terms with which you can dazzle your friends and relations!