Comment on PEP 263 - Defining Python Source Code Encodings

Martin v. Löwis loewis at informatik.hu-berlin.de
Sat May 11 03:46:23 EDT 2002


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

>     	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" />

What is the advantage of this notation? The advantage of the above
notation is that existing editors already recognize it. Compared to
your proposal, it has also the advantage that it is easier to type.

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

Any encoding is acceptable for which a codec is installed. For best
portability, you need to restrict yourself to the encodings supported
in your target Python release.

> I think it has the very positive benefit of using what has rapidly
> become a very familiar idiom

Can you cite other examples of using invalid XML in programming
language comments?

> Do we really need yet _another_ notation?

Precisely my question.

Regards,
Martin





More information about the Python-list mailing list