-2

I am doing some Python programming, and I have a couple of lines that are longer than 120 chars, which is our maximum line width in our coding style guidelines.

Now I was wondering how to do a line break in python, here is an example:

someString = "Here is a [.......] very long text"    # This line is now 130 chars long

And I want something like this:

someString = "Here is a [...]
    [...] very long text"

How can I format my python script like this?

PKlumpp
  • 4,913
  • 8
  • 36
  • 64

2 Answers2

2

Put it in parentheses and split up the lines with open and close quotes - these are automatically concatenated.

someString = ("Here is a [...]"
              "[...] very long text")
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
1
someString = "Here is a [...] \
    [...] very long text"

or

print('Here is a [...]'
      '[...] very long text')

or even

someString = ('Here is a [...]'
              '[...] very long string')

or why not

someString = 'Here is a [...]'
someString += '[...] very long string'
Torxed
  • 22,866
  • 14
  • 82
  • 131