sprintf behaviour

lynx none at of.your.business
Sat Feb 22 18:20:17 CET 2003


On Sat, 22 Feb 2003 15:57:39 +0000, Andrew Wilkinson wrote:

# 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')

well, he *did* say something about wanting positioned parameters. so,
assuming i'm not completely misunderstanding what he meant by that, more
likely he wants to do this:

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

-- 
   PGP/GnuPG key (ID 1024D/3AC87BD1) available from keyservers everywhere
    Key fingerprint = FA8D 5EA4 E7DC 84B3 64BC  410C 7AEE 54CD 3AC8 7BD1
                "...if you can fill the unforgiving minute
                with sixty seconds' worth of distance run..."





More information about the Python-list mailing list