I get the very same behavior if use:
(and same behavior as with Gimp for the first case, too).
I think you are misunderstanding the power of the semicolon in Python, it is not fully equivalent to a line feed. I refer you to the doc:
In other words, you can use the semicolon to make a one-liner with several assignments or even function calls (simple statements), but you cannot separate an if clause (compound statement) from the rest with a semicolon.
Note however that the conditional assignment (Python's equivalent to the ternary operator in C) in a simple statement. So while you cannot write:
you can write:
Code:
>python3 -c 'a="something";if True: print(a);'
File "<string>", line 1
a="something";if True: print(a);
^^
SyntaxError: invalid syntax
(and same behavior as with Gimp for the first case, too).
I think you are misunderstanding the power of the semicolon in Python, it is not fully equivalent to a line feed. I refer you to the doc:
Quote:A suite is a group of statements controlled by a clause. A suite can be one or more semicolon-separated simple statements on the same line as the header, following the header’s colon, or it can be one or more indented statements on subsequent lines.(Emphasis mine)
In other words, you can use the semicolon to make a one-liner with several assignments or even function calls (simple statements), but you cannot separate an if clause (compound statement) from the rest with a semicolon.
Note however that the conditional assignment (Python's equivalent to the ternary operator in C) in a simple statement. So while you cannot write:
Code:
condition=True; if condition: x=foo ; else x=bar; print(x)
you can write:
Code:
condition=True; x="foo" if condition else "bar"; print(x)