[Tutor] question on string
bgailer at sbcglobal.net
Mon Aug 1 20:20:16 CEST 2005
At 10:42 AM 8/1/2005, Gilbert Tsang wrote:
>I would like to construct some string objects using the cprintf-style format:
>command_string = "diff -u %s %s > %s.patch" % ( src, dst, file )
>Of course it is illegal in python
How did you conclude that? "diff -u %s %s > %s.patch" % ( src, dst, file )
is a Python expression, and will do what you want!
See http://docs.python.org/lib/typesseq-strings.html for the official
>but I couldn't figure out a way to
>construct strings with that kind of formatting and substitution.
>I have been looking and couldn't discover string constructor such as
>command_string = string( "diff -u %s %s > %s.patch" % ( src, dst, file ) )
> From the documentation on docs.python.org, the closest is string
>Template (but my python installation doesn't come with this module). Any
>insights on initializing string in this manner?
>Tutor maillist - Tutor at python.org
phone 510 978 4454
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor