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'))
1 Answer 1
interp.exec("import printTwice");
interp.exec("printTwice.print_twice('Adam')");
This should work.
answered Aug 1, 2015 at 16:58
anrodon
5,6211 gold badge29 silver badges51 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
user3742439
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
user3742439
Marvellous, it worked. Thanks Andreu and everyone else that contributed.
default
import os.path.abspath(__file__)/printTwice.py)does not make sense. IfprintTwice.pyis the module that you are trying to import, then the import statement should beimport printTwice.