New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting stdout/stderr from CPython in Java #107

Open
ColdrickSotK opened this Issue Mar 2, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@ColdrickSotK

ColdrickSotK commented Mar 2, 2017

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?

@LeeKamentsky

This comment has been minimized.

Owner

LeeKamentsky commented Mar 2, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment