[Tutor] question on string
Bob Gailer
bgailer at sbcglobal.net
Mon Aug 1 20:20:16 CEST 2005
At 10:42 AM 8/1/2005, Gilbert Tsang wrote:
>Hi there,
>
>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
documentation.
>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?
>
>
>Thanks, Gilbert.
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
Bob Gailer
phone 510 978 4454
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050801/1d8e30d2/attachment.htm
More information about the Tutor
mailing list