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.
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))
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
"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
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,
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
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
"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:
>>
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