redirect python output + extension type with own print method = FAILS
Guido van Rossum
guido at python.org
Sat Aug 11 14:58:39 CEST 2001
Donn Cave <donn at drizzle.com> writes:
> BOTTOMLINE ANSWER: If you want to say "print xxx" and have the
> output go through your stdout - you don't really want a "print"
> method, you want a "repr" method. No I/O, just return a string
> (as in PyString_FromString().) The "print" statement does all the I/O.
Exactly, except strictly speaking, you need a "str" method.
Specifically, the print method only works if sys.stdout is a stdio
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list