help with print function in extension

Alex Martelli aleax at aleax.it
Wed Sep 25 23:15:46 CEST 2002


Eric Hagemann wrote:
        ...
> Alex, Thanks -- missed that section in the manual.  I blindly assumed that
> I could use the repr() as the print func......

You can!  Just leave the tp_print slot to 0 and all should be fine.


> ok so for the next trick question. I implemented a function that has the
> proto
> int print_func(PyObject *obj, FILE *fp,int flags)
> 
> when I try to print to fp -- as in --> fprintf(fp,"<fmt>", , )... I crash
> the program.

I'll have to admit that I never filled tp_print myself (oh the shame),
always relying on other slots, so I can't help you here...


Alex




More information about the Python-list mailing list