How to do a sprintf in Python

So I searched and searched and couldn't find how to do a sprintf in Python. There seemed to be no such routine name. In fact, there’s not! But I was staring right at it. It's simply the % operator, overloaded for strings. Examples:

#!/usr/bin/python -Wall

# ================================================================
# John Kerl
# kerl.john.r@gmail.com
# 2007-05-15
# ================================================================

print "Here %s the number: %d" % ("is", 37)
s =   "Here %s the number: %d" % ("is", 37)
print s

← Back