Skip to content

Redirect std::cout #1005

Closed
Closed
@henryiii

Description

@henryiii

I'm interested in redirecting std::cout for my functions (some of which are long running library functions that report on progress). Is there an officially sanctioned way to redirect std::cout to python's stdout? (other than the custom pybind11::print function)? Running inside of a Jupyter notebook, for example, requires the output go to Python's stdout to be visible.

After lots of googling and some playing around, I've come up with the following solution, which works well. I can make into a PR if this is useful and not already available. It's at https://github.com/GooFit/GooFit/blob/573044ea20eedc8444f38cc6a7ce66bef27d2524/python/Print.cpp .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions