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. Advertising

  2. Vincent Touquet

    Adrian B. Guest

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

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jan Knop
    Replies:
    4
    Views:
    1,053
    Jan knob
    Nov 24, 2003
  2. Vincent  Touquet
    Replies:
    0
    Views:
    444
    Vincent Touquet
    Sep 6, 2004
  3. Michael McGarry
    Replies:
    1
    Views:
    609
    Michael Fuhr
    Dec 16, 2004
  4. Martijn Brouwer

    closing stdin, stdout and stderr

    Martijn Brouwer, Dec 26, 2005, in forum: Python
    Replies:
    5
    Views:
    1,108
    Donn Cave
    Dec 27, 2005
  5. , India

    initialization of stdin, stdout, stderr

    , India, Oct 27, 2008, in forum: C Programming
    Replies:
    5
    Views:
    828
    Phil Carmody
    Oct 28, 2008
Loading...

Share This Page