Julian Berman added the comment:

@Terry IMHO it conflicts with the fundamental description of the function.

> Remove any common leading whitespace from every line in text.

If this behavior is intentional, textwrap.dedent does not do that, it does 
that, but also some other stuff.

As for whether it *should* do that, I can't really see how it'd be a good idea 
to do this -- whether indented blank lines are like trailing whitespace or not 
is a good reason not to *add* them, but if you've got some already, 
textwrap.dedent isn't responsible for them, they were there already.

It is also extremely hard to get the other behavior given a function that does 
this one, but trivial to do the reverse.

Also, the #1 reason to use textwrap.dedent (and also the very next line of the 
docstring after the one I quoted) is to line up sections of source code. With 
this behavior, that usecase goes away any time you need trailing whitespace, 
which is exactly how I found this behavior, by unittesting a function that was 
returning:

textwrap.dedent(
    """
    foo '
        bar
        baz
    

        quux
     '
    """,
)

----------

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

Reply via email to