%s = send object to str() first then drop it into the string
%r = send object to repr() first then drop it into the string
pretty straightforward:
>>> x = 'foo'
>>> str(x)
'foo'
>>> repr(x)
"'foo'"
why do people do %r at all? to get the quotes for free: :-)
>>> x = 'Python'
>>> print "What is this '%s' language?" % x
What is this 'Python' language?
>>> print "What is this %r language?" % x
What is this 'Python' language?
cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
http://corepython.com
wesley.chun : wescpy-gmail.com : @wescpy
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor