# Script help, long jython strings best practices

**URL:** <https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 10, 2024, 1:10pm UTC](https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226 "2024-05-10T13:10:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [May 10, 2024, 1:10pm UTC](https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226/1 "2024-05-10T13:10:30Z")

</div>

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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/01eca2c06a051e4849276b2337cebd455d70be42.png)

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [May 10, 2024, 1:16pm UTC](https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226/2 "2024-05-10T13:16:23Z")

</div>

somethink like

```python
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)

```

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [May 10, 2024, 1:16pm UTC](https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226/3 "2024-05-10T13:16:38Z")

</div>

Try:

```python
query = ('long string '
    'split onto multiple lines')

```

> <https://stackoverflow.com/questions/8577027/how-to-declare-a-long-string-in-python/8578229#8578229>

@sebastien_ng's answer will include the newlines in `test1`, which may or may not be what you want.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 10, 2024, 1:29pm UTC](https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226/4 "2024-05-10T13:29:49Z")

</div>

You can also use this type of syntax:

```python
test = 'Lorem ipsum dolor sit amet, ' \
       'consectetur adipiscing elit, ' \
       'sed do eiusmod tempor incididunt ' \
       'ut labore et dolore magna aliqua.'

print test

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 10, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/script-help-long-jython-strings-best-practices/90226/5 "2024-05-10T14:21:21Z")

</div>

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.
