[Python-ideas] Have a "j" format option for lists

Facundo Batista facundobatista at gmail.com
Thu May 10 09:21:54 EDT 2018


2018-05-10 8:02 GMT-03:00 Rhodri James <rhodri at kynesim.co.uk>:
> On 09/05/18 20:56, Facundo Batista wrote:
>>
>> 2018-05-09 13:48 GMT-03:00 Rhodri James <rhodri at kynesim.co.uk>:
>>
>>> -1 until you give me an actual spec rather than a curious example.
>>>
>>> Sorry if that sounds a bit rude, but I spend most of my time trying to
>>> find
>>
>>
>> Be sorry, it was rude.
>
>
> On reflection, I'm not sorry at all.  It needed to be said, and attempting
> to deduce a spec from a single example has already caused people to go off
> in a variety of different directions.  If provoking you into being even a
> bit more specific gets our collective cat herd moving in something more like
> the same direction, it'll be worth it.

I apologize if *I* was rude or made feel you badly in any way.


> I too didn't equate "j" with "join".  I was somewhat expecting "l" for
> "list" given that "s" for "sequence" is taken.  Should I take it that
> everything from the colon to the "j" is an implicitly delimited string to
> use for joining?

Yes.


> If so, does anything in that string need escaping, like say braces or other
> "j"s?  I'm not sure if format specifiers currently allow arbitrary text (I
> don't think they do, but I'm not sure), which might make this a more serious
> undertaking than it first looks.  Alternatively, are certain characters
> forbidden in this implicit join string?

Don't know.

I think I need to read this for ideas:
https://mail.python.org/pipermail/python-ideas/2015-September/035789.html


> I presume also that no other formatting is possible with this specifier: no
> field widths, no justification, none of the other stuff applicable to
> strings.  I'm not talking about formatting the original strings (or
> whatever) in the list, that would clearly involve crazy amounts of
> sub-formatting and look like a complete mess in the code, but I can see a
> need for formatting the final joined string, and I can't see a way of doing
> that from what you've given us.

I concur, joining *and* do special formatting for the elements would
be a mess. That's way in other mail I said that probably cover the
basic case (doing just str()) is better; if you want something more
complex you always can do it as a separate step :/

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
Twitter: @facundobatista


More information about the Python-ideas mailing list