[Python-ideas] New str whitespace cleaning method?

Jim Jewett jimjjewett at gmail.com
Fri May 24 23:46:52 CEST 2013


On Fri, May 24, 2013 at 4:06 PM, Wolfgang Maier
<wolfgang.maier at biologie.uni-freiburg.de> wrote:
> Triple-quoted strings could be made a subclass of str,

Not really, but the new-prefix solution (d""" ... """) is a moral equivalent.

> and their formatting
> methods (at least strip, lstrip, ljust, rjust) could overwrite those of str
> to operate on a per-line basis, e.g., strip() and lstrip() could remove
> whitespace from the end and the beginning of each line.

I think most use cases treat either all lines or all lines but the
first as a block.
If the 4th line is indented relative to the 3rd, that is probably intentional.

Note that doctests solve a related problem by adding a prefix (">>> "
or "... ") that effectively increases the indent further.

-jJ


More information about the Python-ideas mailing list