[Python-ideas] Printf function?

Carl M. Johnson cmjohnson.mailinglist at gmail.com
Sun May 13 02:49:54 CEST 2012


I was looking at this jokey page on the evolution of programming language syntax -- http://alan.dipert.org/post/153430634/the-march-of-progress -- and it made me think about where Python is now. The Python 2 version of the example from the page is

	print "%10.2f" % x

and the Python 3 is

	print("{:10.2f}".format(x))

Personally, I prefer the new style {} formatting to the old % formatting, but it is pretty busy when you want to do a print and format in one step. Why not add a printf function to the built-ins, so you could just write

	printf("{:10.2f}", x)

Of course, writing a printf function for oneself is trivial and "not every three line function needs to be a built-in," but I do feel like this would be a win for Python's legibility.


What do you all think?


-- Carl Johnson 


More information about the Python-ideas mailing list