Comment on PEP 263 - Defining Python Source Code Encodings

Martin v. Löwis loewis at informatik.hu-berlin.de
Sat May 11 04:19:31 EDT 2002


"David LeBlanc" <whisper at oz.net> writes:

> Firstly it's NOT "invalid xml". It IS a well formed xml tag! 

It is well-formed, but it is invalid - check the XML spec. It violates
at least one validity constraint, namely that the root element must be
declared.

> Secondly, what existing editorS recognize this -*- syntax? (let me guess:
> emacs). 

Right. Also, IDLE supports it with a patch. vim supports it in the form

fileencoding=<encname>

which is also supported by the regular expression.

> Can you cite a better reason for using this syntax then that it's
> used by a particular platform-centric editor?

Why do I need to? Why is that reason not good enough? Notice that
Emacs runs on many platforms. 

> I get the impression that you chose this syntax out of convenience
> for the editor you use more then for any generally useful reason.

If there are other editors that support different means of declaring
the source encoding, we should certainly investigate supporting
them. In fact the current regexp was defined in response to someone
observing that vim also has such a feature (even though it won't work
properly in current vim releases).

Also, the PEP accommodates notepad.exe, by recognizing UTF-8
signatures.

> It might come as a surprise to you, but based on OS installations
> around the world, more people program Python on Windows then all the
> others combined and i'm willing to bet that most of them don't use
> emacs or xemacs or a derivative thereof!

No, but I'm sure that many of them will use notepad or IDLE to edit
Python source code; both are supported by this PEP. I'm also sure that
Pythonwin will implement this PEP sooner or later; if Windows users
stick to using UTF-8 signatures, nearly every editor on Windows will
properly detect the source encoding. Having an XML-like syntax does
not help at all here.

Regards,
Martin





More information about the Python-list mailing list