Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21376
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <moky.math@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.044 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'subject:method': 0.09; 'def': 0.13; '!")': 0.16; 'naive': 0.16; 'partly': 0.16; 'replaces': 0.16; 'subject:set': 0.16; 'cc:addr:python-list': 0.16; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.26; 'module': 0.26; 'fact': 0.27; 'raise': 0.28; 'skip:( 40': 0.28; 'class': 0.29; 'cc:addr:python.org': 0.29; 'remains': 0.30; 'message-id:@gmail.com': 0.31; 'subject:?': 0.31; "i've": 0.32; 'received:209.85.212': 0.33; 'header:User-Agent:1': 0.33; 'latter': 0.34; 'try:': 0.34; '...': 0.35; 'question': 0.36; 'received:google.com': 0.37; 'skip:_ 10': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'except': 0.39; 'received:209': 0.39; 'back': 0.60; 'more': 0.61; 'happen': 0.61; 'subject:best': 0.67; 'to:none': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:newsgroups:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=8rYa1ZXRRarhwBWM0Avrviw+SGQo4dJ2jtx6w7d+dH0=; b=mfKUdpP6kwIPKAdSOwUvmLJOBPd5BTMWQm3oKd1u03vC/DizmUu1dKAW5sI7fvMUOr wmlZxsGBgKqw/eGKWC02e0BVx6h1hvkLV7/U0M+M9bscvnz8RU55ff8oxUqeUBksV5sw fsa2SdNxWocZ/MiA45mDCss6fq8yTOULB3Qf8OJvP9ux9FH+yU7AEFQu0O4cCmeXYaKb fCTO10YsVasDLAdyeLahuEG4es03D6qPUC/O1+H5KJxr5y4RT5N4q4tc/kaDfbv383S5 bNvC7P2Zkwk/px5xAdTOnUWfi/u8auDsy1GgzbpXvmlQTrP7bRLqqHrXG7mbv4w2gsSE Pw9Q== |
| Date | Thu, 08 Mar 2012 07:45:32 +0100 |
| From | Laurent Claessens <moky.math@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.python |
| CC | python-list@python.org |
| Subject | Re: what is best method to set sys.stdout to utf-8? |
| References | <alpine.DEB.2.00.1203072150450.2657@pebbe> <mailman.497.1331165710.3037.python-list@python.org> |
| In-Reply-To | <mailman.497.1331165710.3037.python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.503.1331189452.3037.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1331189452 news.xs4all.nl 6856 [2001:888:2000:d::a6]:34987 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:21376 |
Show key headers only | View raw
> I would. The io module is more recent an partly replaces codecs. The
> latter remains for back compatibility and whatever it can do that io cannot.
I've a naive question : what is wrong with the following system ?
class MyStdOut(object):
def __init__(self):
self.old_stdout=sys.stdout
def write(self,x):
try:
if isinstance(x,unicode):
x=x.encode("utf8")
except (UnicodeEncodeError,UnicodeDecodeError):
sys.stderr.write("This should not happen !")
raise
self.old_stdout.write(x)
sys.stdout=MyStdOut()
... well ... a part of the fact that it is much longer ?
Laurent Claessens
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
what is best method to set sys.stdout to utf-8? Peter Kleiweg <pkleiweg@xs4all.nl> - 2012-03-07 21:57 +0100
Re: what is best method to set sys.stdout to utf-8? Terry Reedy <tjreedy@udel.edu> - 2012-03-07 19:12 -0500
Re: what is best method to set sys.stdout to utf-8? Laurent Claessens <moky.math@gmail.com> - 2012-03-08 07:45 +0100
Re: what is best method to set sys.stdout to utf-8? Laurent Claessens <moky.math@gmail.com> - 2012-03-08 07:45 +0100
csiph-web