-
|
I'm running some Python code from Rust with this: Python::attach(|py| {
let module = py.import("some_module")?;
module
.call_method1("render", (content, id.location()))?
.extract::<SomeText>()
})None of the I'm only trying to debug things and I'd like to add print statements here and there to see what's going wrong 🙂 |
Beta Was this translation helpful? Give feedback.
Answered by
pawamoy
Nov 12, 2025
Replies: 1 comment
-
|
I got something working thanks to another discussion: #[pyclass]
struct LoggingStdout;
#[pymethods]
impl LoggingStdout {
fn write(&self, data: &str) {
println!("stdout from python: {:?}", data);
}
fn flush(&self) {}
}
Python::attach(|py| {
let sys = py.import("sys")?;
let stdout = Py::new(py, LoggingStdout)?;
sys.setattr("stdout", stdout)?;
let module = py.import("some_module")?;
module
.call_method1("render", (content, id.location()))?
.extract::<SomeText>()
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pawamoy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got something working thanks to another discussion: