Skip to content

Instantly share code, notes, and snippets.

@SomberNight
Last active February 20, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SomberNight/5c636a88e951ad4d403b7646d8ac92f0 to your computer and use it in GitHub Desktop.
Save SomberNight/5c636a88e951ad4d403b7646d8ac92f0 to your computer and use it in GitHub Desktop.
Python3 interfaces plaything
from abc import ABC, abstractmethod
class InterfaceA(ABC):
@abstractmethod
def method_a(self) -> None: ...
class InterfaceB(ABC):
@abstractmethod
def method_b(self) -> None: ...
class InterfaceAB(InterfaceA, InterfaceB): pass
class ClassA(InterfaceA):
def method_a(self) -> None:
print("a")
class ClassB(InterfaceB):
def method_b(self: 'InterfaceAB') -> None:
print("b")
self.method_a()
class AB(ClassA, ClassB): pass
ab = AB()
ab.method_b()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment