-
Notifications
You must be signed in to change notification settings - Fork 777
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
print function does not work within rust #660
Comments
you're missing the closing parenthesis didn't test if that fixes it. |
@programmerjake it doesn't, I just bungled copying my example code |
It works here.
$ cat src/main.rs
use pyo3::prelude::*;
use pyo3::types::PyDict;
fn main() {
let gil = Python::acquire_gil();
let py = gil.python();
let locals = PyDict::new(py);
py.run("foo = 'one'; print(foo)", None, Some(locals)).expect("smash");
py.run("print(\"hello python\")", None, None).expect("bang");
println!("hello {}", locals.get_item("foo").unwrap());
}
|
maybe it would work by using |
I think this was probably resolved by #943, so I'm going to close. If anyone encounters this and can provide another repro let's reopen. |
🌍 Environment
rustc --version
): rustc 1.39.0-nightly (17e73e801 2019-08-28)version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
yes💥 Reproducing
Hello! It seems that calling
print()
in a Python snippet from within Rust does not work. I thought that perhaps Pyo3 did something with stdout/stderr file descriptors, but callingimport code; code.interact()
via apy_run!
macro (surprisingly) does work, and everything seems mostly normal (save for sys.argv being an empty list and a few other expected oddities).Obviously this isn't super high priority, but I figured I'd mention it :)
Thanks for such a cool project! Really excited to work with it.
The text was updated successfully, but these errors were encountered: