0

I noticed that Pylance was not giving me an error when I line wrapped a string like this:

>>> print('foo bar'
...   ' and then some.')
foo bar and then some.

I tried it and Python seems to happily concatenate these, as well as simply:

>>> print('foo bar' 'and more')
foo barand more

I thought I needed a + to concatenate. Is this behavior reliable, or should I use + for line wraps, like:

print('This is '
    + 'more readable.')

Thanks

pms1903
  • 1
  • 1
  • This only works with constant strings. It's a feature of Python. You can't write `x y` or `"My Name is" name`. https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation – Frank Yellin Oct 24 '21 at 05:07

0 Answers0