
Guido van Rossum <guido@...> writes:
I don't intend to force the issue. I'm disappointed though -- .format() fixes several common stumbling blocks with %(name)s and at least one with %s.
Everytime I try to experiment a bit with format codes, I find them unintuitively complex:
"{0!r}".format(2.5) '2.5' "{0:r}".format(2.5) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Unknown conversion type r "{0!f}".format(2.5) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Unknown conversion specifier f "{0:f}".format(2.5) '2.500000'
Why must the 'f' code be preceded by a colon rather than by an exclamation mark? There is surely a rational explanation, but in day-to-day use it is really confusing. Add to this the annoyance of typing ".format" and of adding curly braces everywhere, and "%" is clearly handier despite the lonely tuple problem. Regards Antoine.