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?

2
  • 5
    You've marked both questions as duplicates. Surely you'd mark only the latter (chronologically) Commented Dec 30, 2012 at 6:35
  • No, it's like twins. Both should be destroyed. Commented Jul 23, 2013 at 16:14

3 Answers 3

17

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 ...")
Sign up to request clarification or add additional context in comments.

3 Comments

The real answer is 43 but don't tell anyone.
@Janusz Lenar blasphemy, I will not flag you this time but big brother is keeping an eye on you now.
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

Comments

0

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

Check the documentation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.