Re: Format specification mini-language for list joining

2012-11-10 Thread Tobia Conforto
Kwpolska wrote: > > out = 'Temperatures: {0:", ":.1f} Celsius'.format(temps) > > [...] your format is cryptic. Thank you for your criticism, I'll think it over. The reason I find it readable (-enough) is because even without knowing what format language is supported by the temps object, you can

Re: Format specification mini-language for list joining

2012-11-10 Thread Kwpolska
On Sat, Nov 10, 2012 at 5:51 PM, Paul Rubin wrote: > […] Python's format strings are pretty much the same as C's format strings […] You’re thinking about the old % syntax, 'Hello %s!' % 'world'. The OP meant the new str.format syntax ('Hello {}!'.format('world')). --- IMO, the idea is useless.

Re: Format specification mini-language for list joining

2012-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2012 02:26:28 -0800, Tobia Conforto wrote: > Hello > > Lately I have been writing a lot of list join() operations variously > including (and included in) string format() operations. > > For example: > > temps = [24.369, 24.550, 26.807, 27.531, 28.752] > > out = 'Temperatures

Re: Format specification mini-language for list joining

2012-11-10 Thread Paul Rubin
Tobia Conforto writes: > Now, as much as I appreciate the heritage of Lisp, I won't deny than > its format string mini-language is EVIL. ... Still, this is the > grand^n-father of Python's format strings... Without having yet read the rest of your post carefully, I wonder the particular historica

Format specification mini-language for list joining

2012-11-10 Thread Tobia Conforto
Hello Lately I have been writing a lot of list join() operations variously including (and included in) string format() operations. For example: temps = [24.369, 24.550, 26.807, 27.531, 28.752] out = 'Temperatures: {0} Celsius'.format( ', '.join('{0:.1f}'.format(t) for t in temp