On Fri, Apr 30, 2021 at 6:00 PM Chris Angelico <[email protected]> wrote:
For those cases where you're merging literal parts and generated
> parts, it may be of value to use an f-string:
>
> >>> f"[{','.join('0123')}]"
> '[0,1,2,3]'
>
> The part in the braces is evaluated as Python code, and the rest is
> simple literals.
>
For readability, reuse and testing I think it often helps to have a
function (whose name is meaningful). We can get this via
as_list_int_literal = gensep(',', '[', ']')
It would also be nice to allow as_list_int_literal to have a docstring
(which could also be used for testing).
I accept that in some cases Chris's ingenious construction has benefits.
--
Jonathan
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/UVTLPOK4S663GIMSTUWBDMFSFHUEYHGJ/
Code of Conduct: http://python.org/psf/codeofconduct/