[Python-Dev] #pragmas in Python source code

Fred L. Drake, Jr. fdrake@acm.org
Thu, 13 Apr 2000 12:47:52 -0400 (EDT)


Paul Prescod writes:
 > The XML rule is one encoding per file. One thing that I think that they
 > did innovate in (I had nothing to do with that part) is that entities

  I think an important part of this is that the location of the
encoding declaration is completely fixed; it can't start five lines
down (after all, it might be hard to know what a line is!).
  If we say, "The first character of a Python source file must be '#',
or assume native encoding.", we go a long way to figuring out what's a
line (CR/LF/CRLF can be dealt with in a "universal" fashion), so we
can deal with something a little farther down, but I'd hate to be so
flexible that it became too tedious to implement.  I'd be more
accepting of encoding declarations embedded in comments than pragmas.
  (Not that I *like* abusing comments like that.)
  So perhaps a Python encoding declaration becomes:

	#?python encoding="iso-8859-7"?#

  ;)


  -Fred

--
Fred L. Drake, Jr.	  <fdrake at acm.org>
Corporation for National Research Initiatives