Is there a more compact/efficient way of doing this?
for key in kwargs:
if key == 'log':
self.log = kwargs[key]
elif key == 'bin':
self.bin = kwargs[key]
elif key == 'pid':
self.pid = kwargs[key]
elif key == 'conf':
self.conf = kwargs[key]
To achieve exactly what you asked for, you could use
or
However, I would generally prefer something like this:
While this is still somewhat repetitive, the code is really easy to read. All attributes are intialized regardles of whether the corresponding keyword argument is passed in, and the signature of the function clearly documents the arguments and there defaults.