When you do class Derived(BaseKill) the class Derived() now "inherrits" the methods from class BaseKill.
Including foo() and bar().
However you have bar() defined in class Derived() which takes precedent over the "inherrited bar()"
Basically this is similar as doing the following
class Derived():
def foo(self):
print('what is wrong with jpython')
return self.bar()
def bar(self):
print('I am bar')
self.foo()
self.hello()
def hello(self):
print('say Hi')
if __name__== '__main__':
print('what')
c = Derived()
c.bar()
From this code you can clearly see that bar() is calling foo() which in turn is calling bar() again. This is an infinite/recursion.
The error you are seeing is correct.
In your original code you can include some print statements to get the name of the class represented by self, example print(self.__class__.__name__). This can help you further understand the class inheritance.
You might want to look at @staticmethod for BaseKill.bar(), however this will change the functionality, so ensure you test this thoroughly to ensure this is what you want:
class BaseKill():
def foo(self):
print('what is wrong with jpython')
return BaseKill.bar()
@staticmethod
def bar():
print('just chill bar')
return None
class Derived(BaseKill):
def bar(self):
print('I am bar')
self.foo()
self.hello()
def hello(self):
print('say Hi')
if __name__== '__main__':
print('what')
b=BaseKill()
b.foo()
c = Derived()
c.bar()
More information about @staticmethod here
Alternatively you can do the following for foo() in BaseKill:
class BaseKill():
def foo(self):
print('what is wrong with jpython')
return BaseKill.bar(self)