summaryrefslogtreecommitdiff
path: root/python/abstractmethod.py
blob: 9c2f075c482fda7ab04387b8518d80442574aed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from abc import ABC, abstractmethod

class A(ABC):
    def __init__(self):
        pass

    def method(self):
        print("1")

    @abstractmethod
    def x(self):
        pass

class B(A):
    def __init__(self):
        pass

    def method2(self):
        print("2")

class C(B):
    def __init__(self):
        pass

    def method(self):
        print("X")

    def method2(self):
        print("Y")

    def x(self):
        pass

c = C()
c.method()
c.method2()