Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'interpreted': 0.07; 'behavior:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:characters': 0.09; 'subject:script': 0.09; 'encoding': 0.15; 'interpreter': 0.15; 'magic': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:non': 0.16; 'subject:run': 0.16; 'skip:` 20': 0.18; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'error': 0.27; 'run': 0.33; 'mode': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'behavior': 0.61; 'determine': 0.61; 'skip:n 10': 0.62; 'hours': 0.65; 'received:217': 0.66; 'maybe,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: dieter Subject: Re: file.write() of non-ASCII characters differs in Interpreted Python than in script run Date: Wed, 26 Aug 2015 07:51:42 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: pd9e09c33.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) Cancel-Lock: sha1:pwJw9mOQZxkAlGyZZlTbMc+zE5Q= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440568313 news.xs4all.nl 23760 [2001:888:2000:d::a6]:58658 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95643 RAH writes: > I experienced an incomprehensible behavior (I've spent already many hours on this subject): the `file.write('string')` provides an error in run mode and not when interpreted at the console. Maybe, I can explain the behavior: the interactive interpreter uses magic to determine the console's encoding and automatically uses this for console output. No such magic in non-interactive interpreter use. Therefore, you can get "UnicodeEncoding" problems in non-interactive use which you do not see in interactive use.