New submission from 김준환 <xncb...@gmail.com>:

If use textwrap.dedent with string formatting, may get unintended sentences.

For example, a sentence like this:

```
import textwrap

def get_something_string():
    return textwrap.dedent("""\
        test text2
        test text3
        test text4""")

textwrap.dedent(f"""\
    test text1
    {get_something_string()}
    test text5
    test text6""")
```

I look forward to the following results.

```
test text1
test text2
test text3
test text4
test text5
test text6
```

But the actual result is:
```
    test text1
    test text2
test text3
test text4
    test text5
    test text6
```

I understand that this code works in this way because the intent of the string 
defined inside the method is different from the intent of the string outside 
the method.

However, regular users, like me, will think of having a consistent intent 
result value. (because they believe dedent will clear a consistent intent)

If you are concerned that the existing code will be broken, I can implement 
the function using the flag parameter.

If you agree with my opinion, I will submit a PR.

----------
components: Library (Lib)
messages: 414972
nosy: xncbf12
priority: normal
severity: normal
status: open
title: If use textwrap.dedent with string formatting, may get unintended 
sentences.
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

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

Reply via email to