Federer Federer - 1 month ago 19
Python Question

PEP8 - 80 Characters - Big Strings

Due to the sheer annoyance of figuring out what to Google, I've decided to risk what any reputation I had to ask this rather simple question.

As PEP8 suggests keeping below the 80 column rule for your python program, how can I abide to that with long strings, i.e.

s = "this is my really, really, really, really, really, really, really long string that I'd like to shorten."


How would I go about expanding this to the following line, i.e.

s = "this is my really, really, really, really, really, really" +
"really long string that I'd like to shorten."

Answer

Implicit concatenation might be the cleanest solution:

s = "this is my really, really, really, really, really, really," \
    " really long string that I'd like to shorten."

Todd's answer, using brackets rather than line continuation, is better for all the reasons he gives. The only hesitation I have is that it's relatively easy to confuse bracketed strings with tuples.