[Tutor] close, but no cigar

Marc Tompkins marc.tompkins at gmail.com
Tue Jul 23 01:39:05 CEST 2013


On Mon, Jul 22, 2013 at 3:22 PM, Jim Mooney <cybervigilante at gmail.com>wrote:

> On 22 July 2013 14:11, Marc Tompkins <marc.tompkins at gmail.com> wrote:
>
>>
>> One way to deal with this is to specify an encoding:
>>     newchar = char.decode('cp437').encode('utf-8')
>>
>
> Works fine, but I decided to add a dos graphics dash to the existing dash
> to expand the tree
> visually. Except I got a complaint from IDLE that I should add this:
>
> # -*- coding: utf-8 -*-
>
> Will that always work? Setting coding in a comment? Or am I looking at a
> Linux hash line?
>
>
I speak under correction here, but:  what you're setting there is the
encoding for the script file itself (and - the real point here - any
strings you specify, without explicit encoding, inside the script), NOT the
default encoding that Python is going to use while executing your script.
Unless I'm very much mistaken, Python will still use the default encoding
('ascii' in your case) when reading strings from external files.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130722/28b7784c/attachment.html>


More information about the Tutor mailing list