def _fields_list_to_dict(fields, option_name):
 if isinstance(fields, collections.Mapping):
  return fields
 if isinstance(fields, collections.Sequence):
  if (not all((isinstance(field, string_type) for field in fields))):
   raise TypeError(('%s must be a list of key names, each an instance of %s' % (option_name, string_type.__name__)))
  return dict.fromkeys(fields, 1)
 raise TypeError(('%s must be a mapping or list of key names' % (option_name,)))

def _fields_list_to_dict ( fields , option_name ) : if isinstance ( fields , collections . Mapping ) : return fields if isinstance ( fields , collections . Sequence ) : if ( not all ( ( isinstance ( field , string_type ) for field in fields ) ) ) : raise TypeError ( ( '%s must be a list of key names, each an instance of %s' % ( option_name , string_type . __name__ ) ) ) return dict . fromkeys ( fields , 1 ) raise TypeError ( ( '%s must be a mapping or list of key names' % ( option_name , ) ) )
takes a sequence of field names and returns a matching dictionary .