I am attempting to create a method in a base class that allows all subclasses to access the name of the direct parent class from which they inherit. The following code does not work, but how could I implement something similar to this?
class A:
def get_parent_name(self):
return super().__name__
class B(A):
pass
class C(B):
pass
C.get_parent_name()
# Expected output: 'B'
I apologise in advance if this is not a well phrased question. This is my first time posting on Stack Overflow so any advice to improve my questions would also be appreciated