code: def arbitrary_object_to_string(a_thing):
      
      # is it None?
      if a_thing is None:
          return ''
      # is it already a string?
      if isinstance(a_thing, six.string_types):
          return a_thing
      if six.PY3 and isinstance(a_thing, six.binary_type):
          try:
              return a_thing.decode('utf-8')
          except UnicodeDecodeError:
              pass
      # does it have a to_str function?
      try:
          return a_thing.to_str()
      except (AttributeError, KeyError, TypeError):
          # AttributeError - no to_str function?
          # KeyError - DotDict has no to_str?
          # TypeError - problem converting
          # nope, no to_str function
          pass
      # is this a type proxy?
      try:
          return arbitrary_object_to_string(a_thing.a_type)
      except (AttributeError, KeyError, TypeError):
          #
          # nope, no a_type property
          pass
      # is it a built in?
      try:
          return known_mapping_type_to_str[a_thing]
      except (KeyError, TypeError):
          # nope, not a builtin
          pass
      # is it something from a loaded module?
      try:
          if a_thing.__module__ not in ('__builtin__', 'builtins', 'exceptions'):
              if a_thing.__module__ == "__main__":
                  module_name = (
                      sys.modules['__main__']
                      .__file__[:-3]
                      .replace('/', '.')
                      .strip('.')
                  )
              else:
                  module_name = a_thing.__module__
              return "%s.%s" % (module_name, a_thing.__name__)
      except AttributeError:
          # nope, not one of these
          pass
      # maybe it has a __name__ attribute?
      try:
          return a_thing.__name__
      except AttributeError:
          # nope, not one of these
          pass
      # punt and see what happens if we just cast it to string
      return str(a_thing)
docs: take a python object of some sort, and convert it into a human readable
      string.  this function is used extensively to convert things like "subject"
      into "subject_key, function -> function_key, etc.