R. David Murray added the comment:

Actually, we more or less already do have this function in the stdlib, (I'd 
guess it is for pretty much the same reason that QT has it), except ours can 
also truncate sensibly to a given width:

  >>> import textwrap
  >>> textwrap.shorten('  lots\t of\nwhitespace\r\n ', 99999)
  'lots of whitespace'
  >>> textwrap.shorten('  lots\t of\nwhitespace\r\n ', 15)
  'lots of [...]'


That said, if you want *just* the white-space-stripping, the ' 
'.join(s.strip().split()) expression is just as useful and (for what it is 
worth) faster.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to