docs: def str_brief(obj, lim=20, dots='...', use_repr=True):
      """Truncates a string, starting from 'lim' chars. The given object
      can be a string, or something that can be casted to a string.
  
      >>> import string
      >>> str_brief(string.uppercase)
      'ABCDEFGHIJKLMNOPQRST...'
      >>> str_brief(2 ** 50, lim=10, dots='0')
      '11258999060'
      """
      if isinstance(obj, basestring) or not use_repr:
          full = str(obj)
      else:
          full = repr(obj)
      postfix = []
      CLOSERS = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'", '<': '>'}
      for i, c in enumerate(full):
          if i >= lim + len(postfix):
              return full[:i] + dots + ''.join(reversed(postfix))
          if postfix and postfix[-1] == c:
              postfix.pop(-1)
              continue
          closer = CLOSERS.get(c, None)
          if closer is not None:
              postfix.append(closer)
      return full