Does Jython have a ternary operator? I was unable to find it in the guide. edit: I am using weblogic's jython 2.2.1
Asked
Active
Viewed 211 times
1
-
Yes, according to https://stackoverflow.com/a/394814/407651 – mzjn Nov 08 '20 at 07:44
-
@mzjn, I am asking about jython not python – Christos Nov 08 '20 at 13:55
-
Jython implements the same language as "standard" Python (aka CPython). There is no special syntax in Jython that isn't available in CPython. – mzjn Nov 08 '20 at 14:36
-
See https://jython.readthedocs.io/en/latest/LangSyntax/#the-difference-between-jython-and-python – mzjn Nov 09 '20 at 05:26
-
it looks like the version am using doesn't have it. Do you care to formulate an answer? – Christos Nov 09 '20 at 18:53
1 Answers
2
The a if condition else b
syntax was added to the language in version 2.5. It is available in both CPython and Jython.
Jython 2.2.1 is too old and does not support this syntax.

mzjn
- 48,958
- 13
- 128
- 248