java2python
java2python copied to clipboard
Operands for "variable < constant" will be reversed in output as "constant < variable"
As in the title, the parser generally swaps the left and right operands of "<", "<=", ">=", ">" if the right operand is a constant.
class ConditionalOperands {
public static void main(String[] args) {
String s = "abc";
if (abc.length() < 10)
System.out.println("length < 10");
else
System.out.println("length >= 10");
}
}
Python output
""" generated source for module ConditionalOperands """
from __future__ import print_function
# This is the HelloWorld class with a single method.
class ConditionalOperands(object):
""" generated source for class ConditionalOperands """
@classmethod
def main(cls, args):
""" generated source for method main """
s = "abc"
if 10 < len(abc): # <---- This is wrong!
print("length < 10")
else:
print("length >= 10")
if __name__ == '__main__':
import sys
ConditionalOperands.main(sys.argv)