[Tutor] close, but no cigar

eryksun eryksun at gmail.com
Tue Jul 23 01:30:03 CEST 2013


On Mon, Jul 22, 2013 at 6:22 PM, Jim Mooney <cybervigilante at gmail.com> wrote:
> 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:

I presume you copied a Unicode box character from a console window
(not DOS), prompting IDLE to save your file as UTF-8 and insert an
encoding declaration.

> # -*- coding: utf-8 -*-
>
> Will that always work? Setting coding in a comment? Or am I looking at a
> Linux hash line?

Yes, it always works. It's handled by the parser:

    >>> src = '# -*- coding: utf-8 -*-'

    >>> st = parser.suite(src)
    >>> parser.st2list(st)
    [339, [257, [0, '']], 'utf-8']
    >>> symbol.sym_name[339]
    'encoding_decl'


More information about the Tutor mailing list