Created
September 26, 2022 20:14
-
-
Save magickatt/00d9719206d5a9d51422a4f57fbd1f01 to your computer and use it in GitHub Desktop.
Silly example of method overriding using the parent return value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Animal: | |
def what_am_i(self) -> str: | |
return "I am a " | |
class Fox(Animal): | |
def what_am_i(self) -> str: | |
return super().what_am_i() + "Fox" | |
fox = Fox() | |
print(fox.what_am_i()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment