[Tutor] To FORMAT or not to

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Jan 4 23:10:29 EST 2016


Sorry no as that would often leave out data that I consider important. 
I have no interest in whether or not you agree with my opinion.

On 05/01/2016 00:53, Steven D'Aprano wrote:
> On Mon, Jan 04, 2016 at 07:50:59PM +0000, Mark Lawrence wrote:
>> On 03/01/2016 13:12, Alan Gauld wrote:
>
> [snip unnecessary quoting]
>
>>> There are several reasons although your technique is far from
>>> the worst way of doing things. And the format string here would probably
>>> be better written as:
>>>
>>> print("You've visited {0} & {2}.".format(island, new))
> [...]
>
>> Three reasons for why it's better but it doesn't actually work as given.
>
> Mark, please don't bottom-post. That has all the disadvantages of
> top-posting, and none of the advantages. (In other words, it is *worse*
> than top-posting.) Instead, you should trim your quoting and post
> inline.
>
>
>>>>> island = "Isle Of Wight"
>>>>> new = "Isle of Wong"
>>>>> print("You've visited {0} & {2}.".format(island, new))
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> IndexError: tuple index out of range
>
> I think that's an obvious typo that should be {1} instead of {2}.
>
>


-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list