Replies: 1 comment 4 replies
-
Hum, there are two things I don't like about this code -- first, it depends on the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm wondering if something like pybind11's
scoped_ostream_redirect
is available in nanobind?Currently, the output from a C++ function which prints to
std::cout
is only visible in the terminal when running inside a Jupyter notebook.I tried to implement
scoped_ostream_redirect
as a call guard, borrowing code from here, with some success.In the minimal example below I managed to see "before" printed (in both the terminal and a notebook) but not the output from
foo()
or the "after". Moreover, running in the Jupyter notebook ends up killing the kernel before the function returns.My reimplementation is below, almost verbatim from pybind11.
Beta Was this translation helpful? Give feedback.
All reactions