If test1 has to be a very long string, what is best to do to maintain readability?
Just make multiple strings and add them together like test1+test2?
If test1 has to be a very long string, what is best to do to maintain readability?
Just make multiple strings and add them together like test1+test2?
somethink like
test1 = """Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua."""
test2 = " 1020 "
print (test1 +test2)
Try:
query = ('long string '
'split onto multiple lines')
@sebastien_ng's answer will include the newlines in test1
, which may or may not be what you want.
You can also use this type of syntax:
test = 'Lorem ipsum dolor sit amet, ' \
'consectetur adipiscing elit, ' \
'sed do eiusmod tempor incididunt ' \
'ut labore et dolore magna aliqua.'
print test
When I NEED to have a long string literal that's white space sensitive (so, not queries), I use exactly what Felipe suggested.
But if I can, I'd rather have them in a separate file/script, where the length doesn't matter, assigned to a constant, and use that constant where I need the string.