PEP: Defining Python Source Code Encodings
rnd at onego.ru
Wed Jul 18 18:56:42 CEST 2001
On Wed, 18 Jul 2001, M.-A. Lemburg wrote:
>Here's an update of the pre-PEP. After this round of comments, the
>PEP will be checked into CVS (provided Barry assigns a PEP number,
>hi Barry ;-)
> This PEP proposes to introduce a syntax to declare the encoding of
> a Python source file. The encoding information is then used by the
> Python parser to interpret the file using the given encoding. Most
> notably this enhances the interpretation of Unicode literals in
> the source code and makes it possible to write Unicode literals
> using e.g. UTF-8 directly in an Unicode aware editor.
I have not understood: will Unicode encoding be directly allowed or only
ASCII-compatible encodings (like UTF-8)?
> In Python 2.1, Unicode literals can only be written using the
> Latin-1 based encoding "unicode-escape". This makes the
> programming environment rather unfriendly to Python users who live
> and work in non-Latin-1 locales such as many of the Asian
> countries. Programmers can write their 8-bit strings using the
> favourite encoding, but are bound to the "unicode-escape" encoding
> for Unicode literals.
Isn't it time for better gettext support in Python? Then for i18n-enabled
programs, encodings will belong to .mo, .po or whatever called files...
> I propose to make the Python source code encoding both visible and
> changeable on a per-source file basis by using a special comment
> at the top of the file to declare the encoding.
> To make Python aware of this encoding declaration a number of
> concept changes are necessary with repect to the handling of
> Python source code data.
> This PEP only affects Python source code which makes use of the
> proposed magic comment.
> Without the magic comment in the proposed
> position, Python will treat the source file as it does currently
> to maintain backwards compatibility.
This is what I like most. Will optimization be mentioned here?
Sincerely yours, Roman Suzi
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Hard work never killed anyone, but why chance it?" _/
More information about the Python-list