In a dynamic language, why % operator asks user for type info?

Matimus mccredie at
Tue Jul 17 02:30:58 CEST 2007

I don't have a good answer for you, but you might be interested to
read this: Which according to a
recent blog post by BDFL is going to be how string formatting is done
in Python3000.

The character doesn't specify the type to expect, but the formatting
function. So, %s calls a string formatter, %r calls repr and %x calls
a hex formatter. The there may be multiple formatters that produce
different results for given types. An integer can use %d,%e,%f,%s,%x
or %r, and they all produce slightly different results. Also, the
formatters take parameters. Such as "%+010.5f"%(1.23) which produces

More information about the Python-list mailing list