unicode experiments + questions -- PythonWin??

Martin v. Loewis martin at v.loewis.de
Thu Mar 28 05:42:13 EST 2002


"Irmen de Jong" <irmen at NOSPAMREMOVETHISxs4all.nl> writes:

> > The print does not do any conversion; it just sends bytes to the output
> stream.
> Hmm... how does it send the unicode string to the output stream?

It invokes its .write method.

> Not as raw unicode (unconverted), because print redirection throws
> an encoding exception.

Depends on what the output stream is. If it supports Unicode strings
directly, it may be able to write them without converting them. If it
is a file object, the write method invokes the ParseTuple "s"
conversion (actually, "s#" or "t#" depending on binary mode), which in
turn will, for a Unicode object, invoke the default encoding.

Regards,
Martin




More information about the Python-list mailing list