I'm learning Python for a project and am a little puzzled about how to utilise abstraction and classes. (Since I'm not a very skilled coder, please excuse the basic level of my query.) I have a Java/Ocaml background, and what I've been doing is as follows: I have abstract classes that look like this for a graph and a graphadvanced (a graph with some extra fancy functions).
I then have a graph implementation:
My question now is, can I do anything similar?
In other words, how can I describe Advanced's methods abstractly in terms of AbstractGraph's methods, and then feed Graph into a constructorto produce an instance of Advanced that utilises Advanced's definitions with Graph's implementation like this here?
In regards of Ocaml, I'm attempting to treat AbstractAdvanced and AbstractGraph as module types, but I'm not sure how to make this work with Python.
Code:
class AbstractGraph:
def method01(self):
raise NotImplementedError
...
class AbstractAdvanced:
def method02(self):
raise NotImplementedError
...
I then have a graph implementation:
Code:
class Graph(AbstractGraph):
def method01(self):
* actual code *
My question now is, can I do anything similar?
Code:
class Advanced(AbstractAdvanced, AbstractGraph):
def method02(self):
*actual code, using the methods from AbstractGraph*
In other words, how can I describe Advanced's methods abstractly in terms of AbstractGraph's methods, and then feed Graph into a constructorto produce an instance of Advanced that utilises Advanced's definitions with Graph's implementation like this here?
In regards of Ocaml, I'm attempting to treat AbstractAdvanced and AbstractGraph as module types, but I'm not sure how to make this work with Python.