Message371912
The feature of f-strings using '=' for "debugging" formatting is not documented.
>>> foo = 'bar'
>>> f'{foo=}'
"foo='bar'"
I'm not sure where this should fit in to the documentation, but it needs to be in there somewhere.
Basically the documentation needs to say:
1. The entire string from the opening brace { to the start of the expression appears in the output. This allows things like f'{foo = }' to evaluate to "foo = 'bar'" (notice the extra spaces).
2. If no format spec (like :20) is given, repr() is used on the expression. If a format spec is given, then str() is used on the expression. You can use repr() with a format spec by using the !r conversion, like:
>>> f'{foo=:20}'
'foo=bar '
>>> f'{foo=!r:20}'
"foo='bar' " |
|
Date |
User |
Action |
Args |
2020-06-19 23:53:12 | eric.smith | set | recipients:
+ eric.smith, docs@python |
2020-06-19 23:53:12 | eric.smith | set | messageid: <1592610792.76.0.722931750761.issue41045@roundup.psfhosted.org> |
2020-06-19 23:53:12 | eric.smith | link | issue41045 messages |
2020-06-19 23:53:12 | eric.smith | create | |
|