A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-September/017426.html below:

[Python-Dev] why doesn't print pass unicode strings on to the file object?

[Python-Dev] why doesn't print pass unicode strings on to the file object?Martin von Loewis loewis@informatik.hu-berlin.de
Thu, 6 Sep 2001 18:56:57 +0200 (MEST)
> is there any reason why "print" cannot pass unicode
> strings on to the underlying write method?

Mostly because there is no guarantee that every .write method will
support Unicode objects. I see two options: either a stream might
declare itself as supporting unicode on output (by, say, providing a
unicode attribute), or all streams are required by BDFL pronouncement
to accept Unicode objects.

BTW, your wrapper example can be rewritten as

import sys,codecs
sys.stdout = codecs.lookup("iso-8859-1")[3](sys.stdout)

I wish codecs.lookup returned a record with named fields, instead of a
list, so I could write

sys.stdout = codecs.lookup("iso-8859-1").writer(sys.stdout)

(the other field names would be encode,decode, and reader).

Regards,
Martin



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4