Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Last active May 18, 2020 14:32
Show Gist options
  • Save ZhouYang1993/8a9379049c6eec99adb55418e6893eb1 to your computer and use it in GitHub Desktop.
Save ZhouYang1993/8a9379049c6eec99adb55418e6893eb1 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):
print('Animal moves')
class Cat(Animal):
def move(self):
super().move()
print('Cat moves')
c = Cat()
c.move()
# Animal moves
# Cat moves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment