codecs latin1 unicode standard output file

Michael Hudson mwh at python.net
Mon Dec 15 05:38:21 EST 2003


"Marko Faldix" <marko.faldix.tudisweck at mplusr.de> writes:

> Hello,
> 
> with Python 2.3 I can write umlauts (a,o,u umlaut) to a file with this piece
> of code:
> 
>     import codecs
> 
>     f = codecs.open("klotentest.txt", "w", "latin-1")
>     print >>f, unicode("My umlauts are ä, ö, ü", "latin-1")
> 
> 
> This works fine. This is not exactly what I wanted to have. I would like to
> write this to standard output so that I can use same code to produce output
> lines on console or to use this to pipe into file. It was possible before
> Python 2.3. Isn't possible anymore with same code?

If your locale is setup up in an appropriate way, you should be able
to print latin-1 characters to stdout without any intervention at all.

If that doesn't work, we need more details.

Cheers,
mwh

-- 
  Also, remember to put the galaxy back when you've finished, or an
  angry mob of astronomers will come round and kneecap you with a
  small telescope for littering. 
       -- Simon Tatham, ucam.chat, from Owen Dunn's review of the year




More information about the Python-list mailing list