Le 19/06/2011 15:41, candide a écrit :
With Python 2.7 :

  >>>  x="foo"
  >>>  print '"'+x+'"'
"foo"
  >>>


What is this curious syntax on line 2 ? Where is it documented ?

When you want to have an explicit double quote " in a string, you put in between single quote '.
(and vice versa)

So here you have the string
'"'
which is "
then
+x
(add x)
then
+'"'

Try also

>>> print "'"
'
>>> print "'"
"

Laurent
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to