def as_string(self, x):
    """Return a string based on x.id or x.id[x.name]."""
    x_name = self.get_name(x)
    if x is None:
      x_str = 'None'
    elif isinstance(x, sling.Frame) and 'id' in x:
      x_str = x.id
    else:
      try:
        x_str = str(x)
      except UnicodeDecodeError:
        x_str = 'None'
    if FLAGS.show_names:
      return ('%s[%s]' % (x_str, x_name)) if x_name else ('%s[]' % x_str)
    else:
      return x_str
Return a string based on x.id or x.id[x.name].
language/templama/sling2facts.py