print... okay, howabout sprintf?

David Arnold arnold at dstc.monash.edu.au
Sun May 7 03:28:13 EDT 2000


-->"Courageous" == Courageous  <jkraska1 at san.rr.com> writes:

  Courageous> Okay, I've noticed that python print supports printf
  Courageous> style format notation, and that's cool. But how do you
  Courageous> do the same thing with strings. i.e., what's the
  Courageous> equivalent of sprintf()?

it's not print that does this.  the % operator works on any string at
any time.  so you can get sprintf()-like behaviour like

   s = "%s = %d" % ("foo", 34)




d




More information about the Python-list mailing list