# Mistake in Jython interpreter

**URL:** <https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620>\
**Category:** General Discussion\
**Tags:** scripting\
**Created:** [January 23, 2024, 8:40am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620 "2024-01-23T08:40:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacopo\_Ingraito](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Jacopo\_Ingraito](https://forum.inductiveautomation.com/u/Jacopo_Ingraito)\
**Post date:** [January 23, 2024, 8:40am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/1 "2024-01-23T08:40:39Z")

</div>

```auto
a = 'd
b = 123

print a, b

```

If I run these lines the Jython interpreter (on script console) returns me `123 123`  
Has anyone had the same problem or knows the reason?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 8:56am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/2 "2024-01-23T08:56:07Z")

</div>

> [@Jacopo\_Ingraito](#):
>
> `'d`

what is this supposed to be? missing an `'`?

---

<div class="post-metadata">

**Author:** ![Jacopo\_Ingraito](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Jacopo\_Ingraito](https://forum.inductiveautomation.com/u/Jacopo_Ingraito)\
**Post date:** [January 23, 2024, 8:59am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/3 "2024-01-23T08:59:31Z")

</div>

Exactly, I would expect a syntax error

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 9:04am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/4 "2024-01-23T09:04:32Z")

</div>

Seems that this is valid jython sytax 🤷‍♂️ , nothing to do with igntions interpretter. as other jython interpretters have it to.  
Or all interpretters share this bug

---

<div class="post-metadata">

**Author:** ![manuele.longhi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/manuele.longhi/32/51470_2.png) [@manuele.longhi](https://forum.inductiveautomation.com/u/manuele.longhi)\
**Post date:** [January 23, 2024, 9:10am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/5 "2024-01-23T09:10:08Z")

</div>

I tried myself in the script console with Ignition v8.1.27

```python
a = 'd'
b = 123

print a, b
>>> d 123

```

Works just as expected

* * *

```python
a = 'd
b = 123

print a, b
>>> 123 123

```

Works (without giving a syntax error), and prints out 123 123. It kinda looks like it's ignoring the assignment to a, and executing `a=b=123`

* * *

```python
a = 'd

b = 123

print a, b
>>> 123 123

```

(with an extra blank space between the assignment of a and b). Gives Syntax Error, and the code does not execute on the script console.

* * *

I have also tried to execute the same code with a Python interpreter (v2.7), and it always gives a Syntax Error when the string assigned to `a` is not closed

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 9:14am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/6 "2024-01-23T09:14:59Z")

</div>

> [@Jacopo\_Ingraito](#):
>
> returns me `123 123`

Interesting find 👍

```auto
a = "Is this an error?
b =	'Nope, Nothing to see here
c = 123

print type(a), a
print type(b), b
print type(c), c

```

**Output:**

```auto
<type 'int'> 123
<type 'int'> 123
<type 'int'> 123

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 9:16am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/7 "2024-01-23T09:16:13Z")

</div>

got this behavior too on [Online Jython Compiler | Run Jython Code Online](https://www.tutorialspoint.com/execute_jython_online.php)  
(jython v: '2.7.2-DEV )  
soo must be somethignn wrong with jython itself

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 9:19am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/8 "2024-01-23T09:19:56Z")

</div>

It works from a button in the client as well, so in Ignition, it's not limited to the script console.

**Edit:** I wonder if this is related to the fact that the squiggly error line doesn't always show up in the expected place when syntax errors is this nature are made.

---

<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:** [January 23, 2024, 10:13am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/9 "2024-01-23T10:13:07Z")

</div>

Looks like it acts as an "ignore" character for the rest of the line, including the new line. Just take it as a feature !

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 10:13am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/10 "2024-01-23T10:13:59Z")

</div>

I kinda cant believe im not finding anything about this online  
Even this i mean, someone must have had this happen when copying a string or something right?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cb78d398e927d1706739c662d85c083dccd237e1.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 10:27am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/11 "2024-01-23T10:27:26Z")

</div>

> [@pascal.fragnoud](#):
>
> Just take it as a feature !

The only problem I have with what you are saying is that I'm having trouble coming up with any non-mischievous use cases. IMO, it's kind of like `True = False`. It's kinda cool to know that it'll let you do it, but... what good is it?

> [@victordcq](#):
>
> not finding anything

Same here, ...so far, I've found nothing about this anywhere.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 10:32am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/12 "2024-01-23T10:32:28Z")

</div>

> [@justinedwards.jle](#):
>
> Same here, ...so far, I've found nothing about this anywhere.

time to file a bug report to jython i guess

---

<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:** [January 23, 2024, 10:40am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/13 "2024-01-23T10:40:07Z")

</div>

> [@justinedwards.jle](#):
>
> what good is it?

how else are you gonna write this comment ?

```python
a = 2 "let's add 2!
+ 2

```

Are you gonna use parentheses like a barbarian ?

```python
b = (2 # "let's add 2"
+ 2)

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 10:42am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/14 "2024-01-23T10:42:33Z")

</div>

> [@pascal.fragnoud](#):
>
> write this comment ?

Now you're making perfect sense. I was just contemplating my VB days when it was completely appropriate to use unclosed single quotes for commenting.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/89abe6d6cebd0b32f96a6e7b0608d89be4b13d39.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 10:52am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/15 "2024-01-23T10:52:47Z")

</div>

I totally get it now. It allows for a new line with comment, so

```auto
a = 'comment
b = 'comment
c = 123

```

becomes the same thing as:

```auto
a = b = c = 123

```

That actually could be useful for breaking up things like nested comprehensions with comments, so they're not so convoluted. You could potentially get the extra efficiency without the added maintenance cost that comes with difficult to read code. _(Provided the next person who comes along isn't as confused as we were at first"_

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 11:04am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/16 "2024-01-23T11:04:05Z")

</div>

> [@justinedwards.jle](#):
>
> becomes the same thing as:
> 
> ```auto
> a = b = c = 123
> 
> ```

i wonder if it really compiles down to this... or if something weird is going on

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 11:11am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/17 "2024-01-23T11:11:03Z")

</div>

> [@victordcq](#):
>
> if it really compiles down to this

I'd say so:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f7e043b5bdf038be8b45106c5f05cd38de2a1a5d.png)

**Test Code:**

```auto
matrix = [[row * column for column in range(5)] for row in range(3)]

print matrix

sameMatrix = 'We are doing this again, but with our commenting trick
[[row * column 'multiply the row by the column
for column in range(5)] 'for 5 columns
for row in range(3)] # but do it three times

print sameMatrix

```

**Output:**

```auto
[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]
[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 11:13am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/19 "2024-01-23T11:13:01Z")

</div>

wait this allows you to bypass tabs? xD ah no wait its just weird

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/7/174e28ba8ac92661a9b930c58c6437b2527cde03.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2493cdd604d30a12be58a908ed562b79fd563738.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 11:16am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/20 "2024-01-23T11:16:33Z")

</div>

> [@victordcq](#):
>
> its just weird

Is it?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/5/653c668558268a6b289f7dc022bfb537e38b1481.png)

Not so much now that we know it's treated as just one line broken up by comments.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2024, 11:20am UTC](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620/21 "2024-01-23T11:20:04Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ce553f7341fd5312b3b604fc796e5dc506816a0d.png)  
idk, one line broken my a comment on the priviuos line... seems weird to me

funny tho

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/caf6b0cbd9c1478a332712d71949d9aa5e99ac43.png)

[Next page](https://forum.inductiveautomation.com/t/mistake-in-jython-interpreter/84620.md?page=2)
