Last active
October 23, 2020 03:07
-
-
Save skatesham/ef3084d8d23e6fa529ab0126f353cb84 to your computer and use it in GitHub Desktop.
Polymorphism and Abstract Method Overriding implementing an Interface
This file contains 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
from abc import ABC, abstractmethod | |
def main(): | |
for obj in (LocalFinder(), ExternalFinder()): | |
obj.explore() | |
obj.comming_back() | |
class FinderInterface(ABC): | |
@abstractmethod | |
def explore(self) -> str: | |
"""Exploring OOP on Python""" | |
raise NotImplementedError | |
@abstractmethod | |
def comming_back(self) -> str: | |
"""Comming back""" | |
raise NotImplementedError | |
class LocalFinder(FinderInterface): | |
def explore(self): | |
print("Exploring just local") | |
def comming_back(self): | |
print("Back to Local") | |
class ExternalFinder(FinderInterface): | |
def explore(self): | |
print("Exploring from external") | |
def comming_back(self): | |
print("Back to Abroad") | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment