On 2023-04-29 08:31, Matsuoka Takuo wrote:
On Sat, 29 Apr 2023 at 00:52, MRAB <pyt...@mrabarnett.plus.com> wrote:

What happens if you do '{open}...{close}'.partial_format(open='{close}'?
You get '{close}...{close}', and you're going to have a problem using
that as a format string and replacing only the second '{close}'.

Or how about '{open}...{close}'.partial_format(open='{')? You get
'{...{close}'. Try using that as a format string!

That's why I think that the result of a partial format should be an
instance of a new class and not a string.

That's a quite subtle point.  I think
'{open}...{close}'.partial_format(open='{close}') could be the string

   '{open}...{close}'.format(open='{{close}}', close='{close}')

and '{open}...{close}'.partial_format(open='{') could be
'{open}...{close}'.format(open='{{', close='{close}')

You might not know what the replacements are until runtime, so:

    '{open}...{close}'.partial_format(open=opening_item)

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ZBYAULU76TLRZZOH4OMQB5VE74WPCVZE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to