0

I am using Java2Python package to translate a Java project to Python, and I've got an error.

[root@localhost Desktop]# j2py ConfigurationManager.java ConfigurationManager.py
      File "/usr/bin/j2py", line 113
        except (IOError, ), exc:
                          ^
    SyntaxError: invalid syntax

File /usr/bin/j2py, line 113

try:
    if filein != '-':
        source = open(filein).read()
    else:
        source = sys.stdin.read()
except (IOError, ), exc:
    code, msg = exc.args[0:2]
    print 'IOError: %s.' % (msg, )
    return code

If there is any information needed, please tell me.


update

 File "/usr/bin/j2py", line 115
    print 'IOError: %s.' % (msg, )
                       ^
SyntaxError: invalid syntax
6
  • You should read the documentation of the tool you are using. Commented May 16, 2018 at 11:01
  • @Stultuske it seems like the python code in it goes wrong.. Commented May 16, 2018 at 11:07
  • Possible duplicate of Java to python translation with java2python Commented May 16, 2018 at 11:46
  • @NikolayShevchenko I have just deleted that question Commented May 16, 2018 at 11:51
  • @mathews yes, but is it a known problem in the tool? is it a problem in your java code? ... Commented May 16, 2018 at 11:55

1 Answer 1

3

Try this :

except (IOError) as exc:
        for arg in exc.args:
           print(str(arg))
        code = exc.args[0]
        return code

Here I assume that you want to return 1st value in exc.args

Sign up to request clarification or add additional context in comments.

1 Comment

try putting the print statement in paranthesis like print(whatever you want to print)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.