5

I see you guys using

url = '"%s"' % url # This part

>>> url = "http://www.site.com/info.xx"
>>> print url
http://www.site.com/info.xx
>>> url = '"%s"' % url
>>> print url
"http://www.site.com/info.xx"

Is it advanced Python? Is there a tutorial for it? How can I learn about it?

mmattax
  • 26,423
  • 40
  • 113
  • 147
localhost
  • 853
  • 6
  • 12
  • 12

3 Answers3

16

It's common string formatting, and very useful. It's analogous to C-style printf formatting. See String Formatting Operations in the Python.org docs. You can use multiple arguments like this:

"%3d\t%s" % (42, "the answer to ...")
dwc
  • 23,118
  • 7
  • 43
  • 54
8

That line of code is using Python string formatting. You can read up more on how to use it here: http://docs.python.org/library/stdtypes.html#string-formatting

Dan Lew
  • 83,807
  • 30
  • 180
  • 174
0

It is not advanced, you can use ' or " to define a string.

Check the documentation.

Andrea Ambu
  • 36,488
  • 14
  • 52
  • 76