New submission from Eric V. Smith <e...@trueblade.com>:
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' " ---------- assignee: docs@python components: Documentation messages: 371912 nosy: docs@python, eric.smith priority: normal severity: normal stage: needs patch status: open title: f-string's "debug" feature is undocumented versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41045> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com