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