sprintf behaviour

Andrew Wilkinson ajw126NO at SPAMyork.ac.uk
Sat Feb 22 10:57:39 EST 2003


>>> print "-- %2$s -- %1$s --" % ('a', 'b')

Python isn't C you know! You can't simply copy things from C to Python and
expect them to work.

Take a look at...
http://www.python.org/doc/current/lib/typesseq-strings.html

And you'll see that what you actually want is just...
>>> print "-- %s -- %s --" % ('a', 'b')

HTH,
Andrew









More information about the Python-list mailing list