Last active
October 12, 2021 02:43
-
-
Save laalaguer/3501deb2bf83fa7b676cec35eafc2d14 to your computer and use it in GitHub Desktop.
Python Abstract Override can be done with different func params but same name, no error is raised.
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
import abc | |
class A(abc.ABC): | |
@abc.abstractmethod | |
def foo(self): | |
print("abstract foo()") | |
class B(A): | |
def foo(self, who:str): # Note: function signature is different | |
print("hello", who) | |
b = B() | |
b.foo("bar") # hello bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, a class inherit from abc.ABC can be instantiated, provided that it doesn't contain abstract methods.