Python for Entrepreneurs Transcripts
Chapter: Appendix: Python language concepts
Lecture: Concept: Polymorphism

Login or purchase this course to watch this video and the rest of the course contents.
0:00 By leveraging inheritance, we can crate a wide range of types that model our world very well, in this example on the screen we have a wizard
0:09 and the wizard knows how to battle a variety of creatures, we have small animals that are easier to defeat,
0:14 we have standard creatures, we have dragons, we have wizards. All of these types are derived from the creature type.
0:21 Now, the wizard class, you can see, can attack any of these creatures, and the reason the wizard class can attack them
0:27 is it's built, it's programmed to understand what a creature is and attack it and any of the derived classes can be used interchangeably.
0:35 So this means we can continue to evolve and generate new and interesting creature derived types
0:42 and we don't have to change our wizard code to understand how to battle them. That's great, polymorphism is essential in any object-oriented language,
0:51 and that's absolutely true in Python as well.


Talk Python's Mastodon Michael Kennedy's Mastodon