String formatting with %s

Donn donn.ingle at gmail.com
Mon Dec 3 01:25:24 EST 2007


> dictionary-key/value syntax), you can do something like:
> >>> number = lambda x: dict((str(i+1), v) for (i,v) in enumerate(x))
> >>> "%(2)s and %(1)s" % number(["A", "B"])
Whoa - that'll take me a little while to figure out, but it looks intriguing! 
Tah.

\d



More information about the Python-list mailing list