Script help, long jython strings best practices

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?

image

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)
3 Likes

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.

4 Likes

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
4 Likes

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.

2 Likes