code: def repr_feature(feature, max_keys=100, indent=8, lexigraphic=False):
      '''
      generate a pretty-printed string for a feature
      Currently implemented:
        * StringCounter
      @max_keys: truncate long counters
      @indent: indent multi-line displays by this many spaces
      @lexigraphic: instead of sorting counters by count (default), sort
      keys lexigraphically
      '''
      if isinstance(feature, (str, bytes)):
          try:
              ustr = feature.decode('utf8')
              return ustr
          except:
              return repr(feature)
      if isinstance(feature, StringCounter):
          return repr_stringcounter(feature, max_keys, indent, lexigraphic)
      elif isinstance(feature, unicode):
          return feature
      else:
          return repr(feature)
      assert False, 'internal logic failure, no branch taken'