Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Getting stdout/stderr from CPython in Java #107
When running a Python script from inside Java, using CPyhon().exec(script), I couldn't figure out a nice way to obtain the stdout/stderr from the Python script in my Java program. I worked around it by writing to a file instead and reading that file after the fact, but this isn't exactly convenient.
Am I missing something, or if not, is this possible to fix?
It might be a neat idea to have some option to CPython().exec that did the redirection, something like what's done in Python's subprocess module. I don't currently have time to implement something like that, so I'll leave this issue open for now.
Writing to a file is not a bad strategy. You might also consider passing a Java object into your Python script and then your Python script can save your data in the Java object.