1

Here's the link to the problem: Python Interpreter in Jython

The following was a potential solution:

    interp.exec("import os.path.abspath(__file__)/printTwice.py)");
    interp.exec("printTwice.print_twice('Adam')");

However it returned an error:

This returned the following error: Exception in thread "main" SyntaxError: ("mismatched input '(' expecting NEWLINE", ('', 1, 22, 'import os.path.abspath(file)/printTwice.py)\n'))

2
  • import os.path.abspath(__file__)/printTwice.py) does not make sense. If printTwice.py is the module that you are trying to import, then the import statement should be import printTwice. Commented Aug 1, 2015 at 7:17
  • Thanks for helping mzjn. Commented Aug 1, 2015 at 18:58

1 Answer 1

1
interp.exec("import printTwice");
interp.exec("printTwice.print_twice('Adam')");

This should work.

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

2 Comments

Thanks Andreu. I will try this once I figure out how to copy the file into same working directory as Python console. I will let you know if it works
Marvellous, it worked. Thanks Andreu and everyone else that contributed.

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.