Comment on PEP 263 - Defining Python Source Code Encodings

David LeBlanc whisper at oz.net
Sat May 11 03:34:01 EDT 2002


If it's not too late to make any suggestions about this, I have one.

Instead of creating an obscure syntax for encoding as the PEP describes:
	Python will default to ASCII as standard encoding if no other
    	encoding hints are given.

    	To define a source code encoding, a magic comment must
    	be placed into the source files either as first or second
    	line in the file:

          	#!/usr/bin/python
          	# -*- coding: <encoding name> -*-


why not use something like:

		#!/usr/bin/python
		#<python version="2.2.1" encoding="utf-8" />

More generally, "utf-8" would be replaced by one of a list of acceptable
encoding names in the same way as currently envisioned by the PEP authors
(whatever that is - I didn't see it mentioned in the PEP). (I think having a
version attribute is a GOOD thing. I suppose that purists might even wish to
replace "2.2.1" with "http://www.python.org/python-2.2.1", but I don't think
that gains anything.)

This has minor impact on the modifications already needed to implement this
PEP requiring only changes to the Python compiler for recognizing the syntax
used and thus has virtually no impact on anticipated delivery of this
feature. I think it has the very positive benefit of using what has rapidly
become a very familiar idiom and lays an (IMO) good foundation for future
"smart comment" features. It's also worth noting that there are a lot of
tools that know that syntax (setting aside the # of course) already and zero
to none that know "-*-...".

Do we really need yet _another_ notation?

David LeBlanc
Seattle, WA USA






More information about the Python-list mailing list