Author Julian
Recipients Julian, emilyemorehouse, georg.brandl, martin.panter, ncoghlan, pitrou, serhiy.storchaka, terry.reedy
Date 2017-06-27.05:40:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498542021.87.0.11970293192.issue30754@psf.upfronthosting.co.za>
In-reply-to
Content
@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
     '
    """,
)
History
Date User Action Args
2017-06-27 05:40:21Juliansetrecipients: + Julian, georg.brandl, terry.reedy, ncoghlan, pitrou, martin.panter, serhiy.storchaka, emilyemorehouse
2017-06-27 05:40:21Juliansetmessageid: <1498542021.87.0.11970293192.issue30754@psf.upfronthosting.co.za>
2017-06-27 05:40:21Julianlinkissue30754 messages
2017-06-27 05:40:21Juliancreate