printf "fails" in extension

Robert Ferrell ferrell at diablotech.com
Mon Oct 20 13:37:21 EDT 2003


In stuff I write I can use the appropriate Python routines.  However,
part of the task is to extend Python with existing routines by adding
some wrapper code.  That is something I know many others have done,
and is fairly straight forward.  However, I dont' have the liberty of
converting all printf's in the existing code to Python-ese.

Thanks,
-robert

Just <just at xs4all.nl> wrote in message news:<just-438BA6.13395618102003 at news1.news.xs4all.nl>...
> In article <73b00f0c.0310171158.4c05317a at posting.google.com>,
>  ferrell at diablotech.com (Robert Ferrell) wrote:
> 
> > I'm trying to "extend" Python by writing a bit of C code.  I followed
> > the example in the Python documentation, and almost everything works
> > fine.  I can build a DLL, fire up an interactive Python session and
> > import my new module. Methods work almost as expected.
> > 
> > The only problem I'm having is that I can't print to the screen from
> > the C code.  Printing to a file works fine, but neither printf nor
> > fprintf(stdout,...) puts anything onto the screen.
> > 
> > I'm working in Windows2K, using Python2.3.  Is there some trick to get
> > this to work?  I'm wondering if this is a compiler issue (I'm building
> > the DLL using an Absoft compiler).  I googled around looking for
> > relevant information, but I didn't find any.  Perhaps I didn't have
> > the right key words?
> 
> Apart from these potential issues (I know nothing about them), you 
> should really use PySys_WriteStdout() and PySys_WriteStderr(), because 
> these to the right thing when sys.stdout/sys.stderr are redirected to 
> something else.
> 
> Just




More information about the Python-list mailing list