Making an abstract class inherit from another abstract class in python

Squilliam :

Is it possible to have an abstract class inherit abstract methods from another abstract class in python?

If so, how should I do this?

luminousmen :

Have a look at abc module. For 2.7: link. For 3.6: link Simple example for you:

from abc import ABC, abstractmethod

class A(ABC):
    def __init__(self, value):
        self.value = value
        super().__init__()

    @abstractmethod
    def do_something(self):
        pass


class B(A):
    @abstractmethod
    def do_something_else(self):
        pass

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

    def do_something_else(self):
        pass

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make an Abstract Class inherit from another Abstract Class in Python?

From Java

Inherit annotations from abstract class?

From Dev

can abstract class inherit another abstract class c#

From Java

How to call abstract method from abstract class called by inherit class

From Dev

Should a python abstract base class inherit from object

From Dev

How to register classes that inherit from an abstract class in python

From Dev

Making a thread safe class from an abstract class

From Dev

Inherit INotifyPropertyChanged for Static Event from abstract Class

From Java

What is the importance of abstract class that extends from another abstract class

From Dev

Inherit multiple abstract class in java

From Dev

How to inherit abstract class with PyCharm

From Dev

How to test an object class inherit from a certain abstract class

From Dev

Mock class which inherit from abstract class and implements interface

From Dev

Abstract class to instantiate another implemented abstract class

From Dev

Node.js: how to 'inherit' from abstract class?

From Dev

Correct way to inherit from Abstract class with dependent interfaces in C#

From Dev

Is there a way to inherit from a (preferably abstract) base razor class?

From Dev

Doxygen - Inherit documentation from externally documented abstract class

From Dev

@abstractmethod given by a second class to inherit from (multiple inheritance with abstract methods)

From Dev

How to inherit from an abstract class properly in C++?

From Dev

Django - making child class inherit overloaded save method of its parent abstract class

From Dev

Inheritance of abstract class by another abstract and non abstract class

From Dev

Mocking an abstract class derived from an abstract class

From Java

making a class abstract vs making the constructor private

From Dev

Logging from an abstract class

From Dev

inheritance from abstract class

From Dev

Test a abstract class in Python

From Dev

Abstract class Container - Python

From Dev

Generic is an abstract class in python?

Related Related

  1. 1

    How to make an Abstract Class inherit from another Abstract Class in Python?

  2. 2

    Inherit annotations from abstract class?

  3. 3

    can abstract class inherit another abstract class c#

  4. 4

    How to call abstract method from abstract class called by inherit class

  5. 5

    Should a python abstract base class inherit from object

  6. 6

    How to register classes that inherit from an abstract class in python

  7. 7

    Making a thread safe class from an abstract class

  8. 8

    Inherit INotifyPropertyChanged for Static Event from abstract Class

  9. 9

    What is the importance of abstract class that extends from another abstract class

  10. 10

    Inherit multiple abstract class in java

  11. 11

    How to inherit abstract class with PyCharm

  12. 12

    How to test an object class inherit from a certain abstract class

  13. 13

    Mock class which inherit from abstract class and implements interface

  14. 14

    Abstract class to instantiate another implemented abstract class

  15. 15

    Node.js: how to 'inherit' from abstract class?

  16. 16

    Correct way to inherit from Abstract class with dependent interfaces in C#

  17. 17

    Is there a way to inherit from a (preferably abstract) base razor class?

  18. 18

    Doxygen - Inherit documentation from externally documented abstract class

  19. 19

    @abstractmethod given by a second class to inherit from (multiple inheritance with abstract methods)

  20. 20

    How to inherit from an abstract class properly in C++?

  21. 21

    Django - making child class inherit overloaded save method of its parent abstract class

  22. 22

    Inheritance of abstract class by another abstract and non abstract class

  23. 23

    Mocking an abstract class derived from an abstract class

  24. 24

    making a class abstract vs making the constructor private

  25. 25

    Logging from an abstract class

  26. 26

    inheritance from abstract class

  27. 27

    Test a abstract class in Python

  28. 28

    Abstract class Container - Python

  29. 29

    Generic is an abstract class in python?

HotTag

Archive