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'))

asked Jul 31, 2015 at 23:07
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.

answered Aug 1, 2015 at 16:58
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.