Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Last active May 18, 2020 08:20
Show Gist options
  • Save ZhouYang1993/940350eda79fc6da54cff2708d4ed0be to your computer and use it in GitHub Desktop.
Save ZhouYang1993/940350eda79fc6da54cff2708d4ed0be to your computer and use it in GitHub Desktop.
Abstract Classes in Python
from abc import ABC, abstractmethod
class Animal(ABC):
@abstractmethod
def move(self):
pass
a = Animal()
# TypeError: Can't instantiate abstract class Animal with abstract methods move
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