Eric V. Smith <e...@trueblade.com> added the comment:
> 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36817> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com