print() with unicode strings
Eric Brunel
eric.brunel at pragmadev.com
Fri Jun 28 09:46:40 EDT 2002
Thomas Guettler wrote:
> Hi!
>
> >>>print '?' #(German Umlaut)
>
> works
>
> but
>
> >>>print u'?'
>
> does not.
>
> Is there a reason why print does not accept unicode?
> Why not default to a latin-1 encoding?
>
> Version:
>
> Python 2.2 (#1, Dec 31 2001, 15:21:18)
> [GCC 2.95.3-5 (cygwin special)] on cygwin
>
> thomas
To make latin-1 (a.k.a. iso8859-1) or any other your default
encoding, create a file named sitecustomize.py somewhere in your PYTHONPATH
and write in it:
import sys
sys.setdefaultencoding('iso8859-1')
NB: it won't work outside the sitecustomize module (cf.
http://www.python.org/doc/current/lib/module-sys.html#l2h-264 )
HTH
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list