[Python-ideas] new format spec for iterable types

Sven R. Kunze srkunze at mail.de
Tue Sep 8 19:49:39 CEST 2015


On 08.09.2015 12:00, Wolfgang Maier wrote:
>
> head = 99
> data = myList(range(10))
> s = '{}, {:*, }'.format(head, data)
> # or
> s2 = '{}{sep}{:*{sep}}'.format(head, data, sep=', ')
> print(s)
> print(s2)
> # 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>
> Thoughts?

I like it and I agree this is an oft-used pattern. From my experience I 
can tell patterns are workarounds if a language cannot handle it properly.

I cannot tell what a concrete syntax would exactly look like but I would 
love to see an easy-to-read solution.

Best,
Sven


More information about the Python-ideas mailing list