Re: Single format descriptor for list

2016-01-21 Thread Paul Appleby
Thanks all for the answers. Oscar Benjamin wrote: print(('{}th\n' * len(a)).format(*a)) print(''.join(map('{}th\n'.format, a))) Those two look closest to what I was hoping for, I guess, but as Chris Angelico said, it probably is clearer to just loop over the range. -- https://mail.

Re: Single format descriptor for list

2016-01-20 Thread Grobu
On 20/01/16 10:35, Paul Appleby wrote: In BASH, I can have a single format descriptor for a list: $ a='4 5 6 7' $ printf "%sth\n" $a 4th 5th 6th 7th Is this not possible in Python? Using "join" rather than "format" still doesn't quite do the job: a = range(4, 8) print ('th\n'.join(map(str,a))

Re: Single format descriptor for list

2016-01-20 Thread Mark Lawrence
On 20/01/2016 09:35, Paul Appleby wrote: In BASH, I can have a single format descriptor for a list: $ a='4 5 6 7' $ printf "%sth\n" $a 4th 5th 6th 7th Is this not possible in Python? Using "join" rather than "format" still doesn't quite do the job: a = range(4, 8) print ('th\n'.join(map(str,a

Re: Single format descriptor for list

2016-01-20 Thread Jussi Piitulainen
"Frank Millman" writes: > "Paul Appleby" wrote in message > news:pan.2016.01.20.09.35.09@nowhere.invalid... >> >> In BASH, I can have a single format descriptor for a list: >> >> $ a='4 5 6 7' >> $ printf "%sth\n" $a >> 4th >> 5th >> 6th >> 7th >> >> Is this not possible in Python? Using "join" r

Re: Single format descriptor for list

2016-01-20 Thread Oscar Benjamin
On 20 January 2016 at 09:35, Paul Appleby wrote: > In BASH, I can have a single format descriptor for a list: > > $ a='4 5 6 7' > $ printf "%sth\n" $a > 4th > 5th > 6th > 7th > > Is this not possible in Python? Using "join" rather than "format" still > doesn't quite do the job: > a = range(4,

Re: Single format descriptor for list

2016-01-20 Thread Chris Angelico
On Wed, Jan 20, 2016 at 8:35 PM, Paul Appleby wrote: > In BASH, I can have a single format descriptor for a list: > > $ a='4 5 6 7' > $ printf "%sth\n" $a > 4th > 5th > 6th > 7th > > Is this not possible in Python? Using "join" rather than "format" still > doesn't quite do the job: > a = rang

Re: Single format descriptor for list

2016-01-20 Thread Ben Finney
Paul Appleby writes: > In BASH, I can have a single format descriptor for a list: > […] > Is this not possible in Python? Not as such; you'll need to treat items differently from sequences of items. > Using "join" rather than "format" still doesn't quite do the job: Right, ‘str.join’ is meant

Re: Single format descriptor for list

2016-01-20 Thread Frank Millman
"Paul Appleby" wrote in message news:pan.2016.01.20.09.35.09@nowhere.invalid... In BASH, I can have a single format descriptor for a list: $ a='4 5 6 7' $ printf "%sth\n" $a 4th 5th 6th 7th Is this not possible in Python? Using "join" rather than "format" still doesn't quite do the job: >>

Single format descriptor for list

2016-01-20 Thread Paul Appleby
In BASH, I can have a single format descriptor for a list: $ a='4 5 6 7' $ printf "%sth\n" $a 4th 5th 6th 7th Is this not possible in Python? Using "join" rather than "format" still doesn't quite do the job: >>> a = range(4, 8) >>> print ('th\n'.join(map(str,a))) 4th 5th 6th 7 Is there an eleg