I recently started coding in Python and I have a question about the **kwargs parameter and class initialization.
In the case of the following class instantiation and init method, how do I know what is stored in **kwargs? In this case, 'net' is a python dictionary containing different keys. Are those keys loaded into the **kwargs parameter? Furthermore, if I try to print **kwargs in the init method it is not outputting any print to the python console, why is this? Am I not allowed to print inside the init method?
Thank you.
''' instantiation '''
sf = op.algorithms.StokesFlow(network=net, phase=water)
''' __init__ method of the StokesFlow class '''
def __init__(self, settings={}, phase=None, **kwargs):
def_set = {'phase': None,
'quantity': 'pore.pressure',
'conductance': 'throat.hydraulic_conductance',
'gui': {'setup': {'phase': None,
'quantity': '',
'conductance': ''},
'set_rate_BC': {'pores': None,
'values': None},
'set_value_BC': {'pores': None,
'values': None},
'set_source': {'pores': None,
'propname': ''}
}
}
print("kwargs:", **kwargs)
super().__init__(**kwargs)
self.settings.update(def_set)
self.settings.update(settings)
if phase is not None:
self.setup(phase=phase)