[Python-ideas] new format spec for iterable types

Sven R. Kunze srkunze at mail.de
Tue Sep 8 20:21:53 CEST 2015

On 08.09.2015 19:58, Chris Angelico wrote:
> It'd be rather cool if it could be done as a special format string,
> though, which says "here's a separator, here's a format string, now
> iterate over the argument and format them with that string, then join
> them with that sep, and stick it in here". It might get a bit verbose,
> though.

Most of the time, the "format string" of yours I use is "str". So, 
defaulting to "str" would suffice at least from my point of view:

output = f'Have a look at this comma separated list: {fruits#, }.'

Substitute # by any character that you see fit.

I mean, seriously, you don't use a full-featured template engine, throw 
an iterable into it and hope that is just works and provides some 
readable output. Job done and you can move on.

What do you expect? From my point of view, the str + join suffices for 
once again 80% of the use-cases.


More information about the Python-ideas mailing list