def attr_from_kwargs(obj, kwargs, attr, value = None):
  """
  If an attribute is in the kwargs dictionary, then assign it to the
  given object and remove it from the dictionary, otherwise assign 
  the default value
  """
  if attr in kwargs:
    setattr(obj, attr, kwargs[attr])
    del kwargs[attr]
  else:
    setattr(obj, attr, value)
dataset/ETHPy150Open iskandr/parakeet/parakeet/c_backend/pymodule_compiler.py/attr_from_kwargs/original