I am trying to learn more about Python - I am using 3.6.3 currently.
What is the best practice for argument validation/parsing when using kwargs?
Or, what is the best practice for argument validation/parsing without kwargs?
class foo:
def __init__(self, **kwargs):
if 'a' in kwargs:
self.a = kwargs['a']
else:
self.a = 0
class bar(foo):
def __init__(self, **kwargs):
super().__init__()
if 'x' in kwargs:
self.x = kwargs['x']
else:
self.x = 23
# b and y are undefined, but my classes use kwargs - what is the best practice for validating / parsing dynamic arguments?
test = bar(b=1,y=24)