def limit_length(s, length):
 if (s is None):
  return None
 ELLIPSES = u'...'
 if (len(s) > length):
  return (s[:(length - len(ELLIPSES))] + ELLIPSES)
 return s

def limit_length ( s , length ) : if ( s is None ) : return None ELLIPSES = u'...' if ( len ( s ) > length ) : return ( s [ : ( length - len ( ELLIPSES ) ) ] + ELLIPSES ) return s
add ellipses to overly long strings .