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

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,

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) >>&g

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 "form

Re: Single format descriptor for list

2016-01-20 Thread Oscar Benjamin
On 20 January 2016 at 09:35, Paul Appleby <pap@nowhere.invalid> 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 "

Re: Single format descriptor for list

2016-01-20 Thread Ben Finney
Paul Appleby <pap@nowhere.invalid> 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"

Re: Single format descriptor for list

2016-01-20 Thread Chris Angelico
On Wed, Jan 20, 2016 at 8:35 PM, Paul Appleby <pap@nowhere.invalid> 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 "

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,

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 >> 4t