.format vs. %

Alexander Kapps alex.kapps at web.de
Sat Dec 31 13:59:19 EST 2011


On 31.12.2011 19:44, davidfx wrote:
> Thanks for your response.  I know the following code is not going to be correct but I want to show you what I was thinking.
>
> formatter = "%r %r %r %r"
>
> print formatter % (1, 2, 3, 4)
>
> What is the .format version of this concept?
>

formatter = "{0} {1} {2} {3}"
formatter.format(1,2,3,4)


I have to say, I simply hate .format(), and I will be very, very 
upset if classic formatting will really be removed.

I understand that .format() has a lot of advantages for more complex 
formatting, but for the simple stuff I usually do, it's just 
terribly inconvenient (try {} on a German keyboard).



More information about the Python-list mailing list