[New-bugs-announce] [issue41312] add !p to pprint.pformat() in str.format() an f-strings
Charles Machalow
report at bugs.python.org
Thu Jul 16 00:17:41 EDT 2020
New submission from Charles Machalow <csm10495 at gmail.com>:
Right now in str.format(), we have !s, !r, and !a to allow us to call str(), repr(), and ascii() respectively on the given expression.
I'm proposing that we add a !p conversion to have pprint.pformat() be called to convert the given expression to a 'pretty' string.
Calling
```
print(f"My dict: {d!p}")
```
is a lot more concise than:
```
import pprint
print(f"My dict: {pprint.pformat(d)}")
```
We may even be able to have a static attribute stored to change the various default kwargs of pprint.pformat().
----------
components: IO, Library (Lib)
messages: 373738
nosy: Charles Machalow
priority: normal
severity: normal
status: open
title: add !p to pprint.pformat() in str.format() an f-strings
type: enhancement
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41312>
_______________________________________
More information about the New-bugs-announce
mailing list