Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Created May 18, 2020 07:52
Show Gist options
  • Save ZhouYang1993/17351c15142452bb7a8f18d56260c3a8 to your computer and use it in GitHub Desktop.
Save ZhouYang1993/17351c15142452bb7a8f18d56260c3a8 to your computer and use it in GitHub Desktop.
Abstract classes in Python
#### example 1
class Animal(ABC):
@abstractmethod
def move(self):
pass
a = Animal()
# TypeError: Can't instantiate abstract class Animal with abstract methods move
#### example 2
class Animal():
@abstractmethod
def move(self):
pass
a = Animal() # No errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment