[Tutor] string formatting

Matthew Pirritano matthewpirritano at sbcglobal.net
Sun Sep 18 01:51:19 CEST 2011


All,

 

I know that I can do this:

 

"the %s is %s" % ('sky', 'blue')

 

But I have very large blocks of text and I thought there was another way
like

 

X = "sky"

Y = "blue"

 

"the %(X)s is %(Y)s"

 

But I've tried this and it is not working. I'm just trying to get it to work
in the interpreter right now.

 

I'm using python 2.6.5. I need to use this version because it is compatible
with the software that it is working with (SPSS).

 

What am I missing?

 

Thanks

Matt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110917/540c6d4e/attachment.html>


More information about the Tutor mailing list