java2python icon indicating copy to clipboard operation
java2python copied to clipboard

Operands for "variable < constant" will be reversed in output as "constant < variable"

Open jbarlow83 opened this issue 9 years ago • 0 comments

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)

jbarlow83 avatar Aug 02 '16 07:08 jbarlow83