code: def namespace_to_dict(obj):
      
      if isinstance(obj, (argparse.Namespace, optparse.Values)):
          return vars(obj)
      return obj
docs: If obj is argparse.Namespace or optparse.Values we'll return
        a dict representation of it, else return the original object.
  
      Redefine this method if using other parsers.
  
      :param obj: *
      :return:
      :rtype: dict or *