Comment on PEP 263 - Defining Python Source Code Encodings

David LeBlanc whisper at oz.net
Sat May 11 05:39:02 EDT 2002


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Martin v. Lowis
> Sent: Saturday, May 11, 2002 1:20
> To: David LeBlanc
> Cc: Python-List at Python. Org; mal at lemburg.com
> Subject: Re: Comment on PEP 263 - Defining Python Source Code Encodings
>
>
> "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.

XML is used far more often in "well formed" contexts than in "valid"
contexts. This is hair splitting.

> > 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.

Let's see, you're saying here that only emacs supports it trivially: idle
needs a patch and vim uses an alternate syntax (which, below, you say is
broken), which isn't clearly mentioned in the PEP I believe?

> > 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.

Yes emacs runs on many platforms. On most of them, poorly and with a reduced
feature set (this is certainly true of my several experiments with using
emacs and xemacs on Windows). I've met more people using notepad then emacs
on Windows, and virtually no programmers uses notepad for development. I am
willing to believe that more people use idle then notepad on Windows though.

> > 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).

Vim, like emacs, has a spotty track record wrt to features and stability on
Windows. I used vim for about 5 years on both NT and Windows 2000 until my
frustrations exceded it's utility to me. Like emacs, Vim works best on
Unix-family OS's.

> 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.

I would guess more people use idle then notepad and, especially if they're
professional developers, use neither. I don't think that the editor people
use is the point here though. While I can't name any specific tools that use
xml embedded in comments right this minute, I have seen such tools and have
not seen tools that use -*- (you yourself cite only one). Can you honestly
say that this syntax offers a more flexible base for possible future "smart
comments"?

Actually, for something as important as encoding, I think using "smart
comments" for a feature that is known to the compiler is a mistake and
"pragma encoding='encoding_name'" makes far more sense, but I doubt that
would fly. I can live with "smart comments", but I think the syntax you've
chosen is kludgy and limiting.

> Regards,
> Martin

Dave LeBlanc
Seattle, WA USA






More information about the Python-list mailing list