[issue36774] f-strings: Add a !d conversion for ease of debugging

Serhiy Storchaka report at bugs.python.org
Thu May 2 12:30:53 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

To implement converting printf-style string formatting into f-string expressions (see issue28307) I need to add new convertors:

'd': int(x) where x is a number, used for %d, %u, %i
'i': operator.index(i), used for %x, %o, %b
'f': float(x) where x is a number, used for %f, %g, %e

They may be private, only exposed in the AST between optimizer and code generator. But they can also be supported by Python grammar and str.format() if there is a use case for this.

If 'd' be used for other purposes, I will need to find other character for converting a number to integer (with possible truncation). Any suggestions?

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36774>
_______________________________________


More information about the Python-bugs-list mailing list