[issue36310] pygettext3.7 Does Not Recognize gettext Calls Within fstrings

Eric V. Smith report at bugs.python.org
Thu May 9 13:44:22 EDT 2019


Eric V. Smith <eric at trueblade.com> added the comment:

Thanks for adding me, Toshio.

    foo = f'{_(f"{first}, bar, and {last}")}'

Wow, that's extremely creative.

I agree that this isn't the best we can do. PEP 501 has some ideas, but it might be too general purpose and powerful for this. Let me think about the nested f-string above and see if I can't think of a better way.

As an aside, this code:

foo = _("{first}, bar, and {last}").format(**globals())

Is better written with format_map():

foo = _("{first}, bar, and {last}").format_map(globals())

It does not create a new dict like the ** version does.

----------

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


More information about the Python-bugs-list mailing list