
April 30, 2021
5:10 p.m.
On Fri, Apr 30, 2021 at 6:00 PM Chris Angelico <rosuav@gmail.com> 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