I’d like to do something like this:
class A(object):
def __init__(self, **kwargs):
"""
return exception if certain arguments not set
"""
class B(A):
def __init__(self, **kwargs):
super(B, self).__init__(**kwargs)
Basically, each subclass will require certain arguments to be properly instantiated. They are the same params across the board. I only want to do the checking of these arguments once. If I can do this from the parent init() – all the better.
Is it possible to do this?
Sure. This is not an uncommon pattern:
This also insulates you a little from
supershenanigans: nowA‘s argspec can change without requiring any edits toB, and diamond inheritance is a little less likely to break.