Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web scraping application that contains long string literals for the URLs. What would be the best way to present them (keeping in mind that I would like to adhere to PEP-8.

URL = ""
br = mechanize.Browser()

I had thought to do this:

URL_SUFFIX = "bar-app/abc/hello/world/AndThen"
URL_ARGUMENTS = "?whatever=123&this=456&theother=789&youget=the_idea"
br = mechanize.Browser() + URL_SUFFIX + URL_ARGUMENTS)

But there are many lines and it's not a standard way of representing a URL.

share|improve this question
I would put the URLS in a config file, or take them as a parameter. – konijn Feb 13 '13 at 14:25

You could use continuation lines with \, but it messes the indentation:

URL = '\

Or you could use the fact that string literals next to each other are automatically concatenated, in either of these two forms:

URL = (''

URL = '' \
      'bar-app/abc/hello/world/AndThen' \

I often use the parenthesized version, but the backslashed one probably looks cleaner.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.