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?
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?
what is this supposed to be? missing an '
?
Exactly, I would expect a syntax error
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
I tried myself in the script console with Ignition v8.1.27
a = 'd'
b = 123
print a, b
>>> d 123
Works just as expected
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
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
Interesting find
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:
<type 'int'> 123
<type 'int'> 123
<type 'int'> 123
got this behavior too on Online Jython Compiler | Run Jython Code Online
(jython v: '2.7.2-DEV )
soo must be somethignn wrong with jython itself
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.
Looks like it acts as an "ignore" character for the rest of the line, including the new line. Just take it as a feature !
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?
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?
Same here, ...so far, I've found nothing about this anywhere.
time to file a bug report to jython i guess
how else are you gonna write this comment ?
a = 2 "let's add 2!
+ 2
Are you gonna use parentheses like a barbarian ?
b = (2 # "let's add 2"
+ 2)
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.
I totally get it now. It allows for a new line with comment, so
a = 'comment
b = 'comment
c = 123
becomes the same thing as:
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"
i wonder if it really compiles down to this... or if something weird is going on
I'd say so:
Test Code:
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:
[[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]]
Is it?
Not so much now that we know it's treated as just one line broken up by comments.