embedding Python and changing stdin, stdout and stderr

Discussion in 'Python' started by Vincent Touquet, Sep 2, 2004.

  1. Hi,

    In a project where I have embedded Python in a C++ application, I have
    the need to replace what Python considers to be stdin, stdout and/or
    stderr.

    In sysmodule.c in the Python sources, I find the following lines of
    code:

    sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL);
    ....
    PyDict_SetItemString(sysdict, "stdin", sysin);

    Where stdin is the C constant FILE pointer and sysin is a PyObject
    pointer.

    Would it be feasible for me to provide my own PyFile to replace sysin
    in sysdict ? It would seem to me that it would be sufficient to
    provide the Python interpreter with a different standard in/out/err
    than the one provide by the OS (through C).

    best regards,

    Vincent
     
    Vincent Touquet, Sep 2, 2004
    #1
    1. Advertisements

  2. Vincent Touquet

    Adrian B. Guest

    Adrian B., Sep 3, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.