Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

I've been using this older c-style substitution in Python: "Hello, %s!" % name Apparently there is a newer way of substituting variables. Can someone fill me in on this? Thanks.

OpenStudy (anonymous):

The other way to format that I know of is to create a dictionary, i.e.: print 'This %(name)s is wrong by %(#)d' % {'name' : 'sentence', '#': 4}. I do think that Python 3.x has another way to format, but I don't really remember it. I will look into it :-)

OpenStudy (anonymous):

Ah, found it. According to the BDFL's Introduction to Python, one should use str.format because of deprecation. Check this example: http://codepad.org/GSOQwMB8

OpenStudy (anonymous):

Great! Thanks, bmp.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
3 days ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
3 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!