[Python-Dev] directive statement (PEP 244)

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Tue, 17 Jul 2001 00:01:37 +0200

> > A programmer
> > can still add some editor specific comment to the source file
> > to tell the editor in what encoding to display the file, but this
> > information is really only useful for the editor, not the
> > Python compiler.
> This redundancy worries me though.  Are we going to encourage people
> to use an editor-specific comment for each editor out there that could
> be used to touch the file?

For non-ASCII source code? Certainly, this is the only option
(although many editors might chose a "display something, even as
garbage" mode without being further instructed).

We cannot expect all editors to correctly detect the encoding. So if
some provide customization through comments, users will use that. A
dedicated Python editor would look at the encoding directive, of

> Yes, and so would removing a directive.  I don't see the point at
> all.

It contradicts what most users expect from comments, and contradicts
what the language reference says:

# Comments are ignored by the syntax; they are not tokens.

Comments are ignored; putting a meaning into them for program
execution is a hack.

> Directives come with their own set of magic.

There is no magic to the directive statement. Instead, it does what
all statements do: It has a certain meaning to the language. Python
has few declarations, the directive statement would be one of them.
Is that bothering you?