Message297007
@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
'
""",
) |
|
Date |
User |
Action |
Args |
2017-06-27 05:40:21 | Julian | set | recipients:
+ Julian, georg.brandl, terry.reedy, ncoghlan, pitrou, martin.panter, serhiy.storchaka, emilyemorehouse |
2017-06-27 05:40:21 | Julian | set | messageid: <1498542021.87.0.11970293192.issue30754@psf.upfronthosting.co.za> |
2017-06-27 05:40:21 | Julian | link | issue30754 messages |
2017-06-27 05:40:21 | Julian | create | |
|