Message341696
> In you example the format spec is applied to both the value and the literal representation of the expression. Is it an error? I do not think this is an expected behavior.
No, you're misreading it. I admit that my example wasn't great. Try this one:
>>> for n in nums:
... print(f'*{n=:+<30}*')
...
*n=0.3333333333333333++++++++++++*
*n=1.0+++++++++++++++++++++++++++*
*n=10.0++++++++++++++++++++++++++*
*n=3.141592653589793+++++++++++++*
> If you want to apply it to both the literal expression and its value you can use the nested f-string: f"*{f'{n=}':30}*".
Correct. There's a similar discussion in issue36774. |
|
Date |
User |
Action |
Args |
2019-05-07 08:17:50 | eric.smith | set | recipients:
+ eric.smith, barry, larry, serhiy.storchaka, levkivskyi |
2019-05-07 08:17:50 | eric.smith | set | messageid: <1557217070.22.0.961332864006.issue36817@roundup.psfhosted.org> |
2019-05-07 08:17:50 | eric.smith | link | issue36817 messages |
2019-05-07 08:17:50 | eric.smith | create | |
|