[Python-ideas] New str whitespace cleaning method?
Serhiy Storchaka
storchaka at gmail.com
Tue May 21 14:52:30 CEST 2013
21.05.13 15:07, Joao S. O. Bueno написав(ла):
> What about an STR method for just formatting whitespace?
>
> I propose starting with something that would just replace all occurrences of
> white-space sequences with a single white-space,
' '.join(text.split())
> and another mode that does the same, but preserves newlines.
'\n'.join(' '.join(line.split()) for line in text.split('\n'))
More information about the Python-ideas
mailing list