Let's suppose we have this parent class:
class Parent:
def __init__(self):
pass
And these two children:
class Child1(Parent):
def __init__(self, 1stparam):
pass
class Child2(Parent):
def __init__(self, 1stparam, 2ndparam):
pass
I would like a method for class Parent
to check if the arguments passed are negative. For example:
class Parent:
def __init__(self):
pass
def check_data( allparameters ):
if allparameters <0:
return false
I would like to check_data
for all childs by inheriting this method, for example:
mychild1 child1(-1)
mychild2 child2(1, -1)
[mychild1.check_data(), mychild2.check_data()]
This should return, of course, [False, False]
.