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

Rhodri James rhodri at kynesim.co.uk
Wed May 9 12:48:37 EDT 2018


On 09/05/18 13:39, Facundo Batista wrote:
> This way, I could do:
> 
>>>> authors = ["John", "Mary", "Estela"]
>>>> "Authors: {:, j}".format(authors)
> 'Authors: John, Mary, Estela'
> 
> In this case the join can be made in the format yes, but this proposal
> would be very useful when the info to format comes inside a structure
> together with other stuff, like...
> 
>>>> info = {
> ...   'title': "A book",
> ...   'price': Decimal("2.34"),
> ...   'authors: ["John", "Mary", "Estela"],
> ... }
> ...
>>>> print("{title!r} (${price}) by {authors:, j}".format(**info))
> "A book" ($2.34) by John, Mary, Estela
> 
> What do you think?

-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 polite ways to inform people that I'm perfectly capable of 
implementing the fluffy collection of vague aspirations and inconsistent 
terminology they have given me, but the results won't be what they 
expect and probably won't be what they want either.  And that's just 
talking to my boss :-)  If you want something specific you'll have to 
specify it, otherwise you'll get something else.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-ideas mailing list