PEP: Defining Unicode Literal Encodings (revision 1.1)

M.-A. Lemburg mal at lemburg.com
Sat Jul 14 12:04:04 EDT 2001


Roman Suzi wrote:
> 
> On Sat, 14 Jul 2001, M.-A. Lemburg wrote:
> 
> >directive unicodeencoding = 'latin-1'
> 
> >#!/usr/local/python
> >""" Module Docs...
> >"""
> >directive unicodeencoding = 'latin-1'
> >...
> >u = "Héllô Wörld !"
> >...
> 
> Is there any need for new directive like that?
> Maybe it is possible to use Emacs-style "coding" directive
> in the second line instead:
> 
> #!/usr/bin/python
> # -*- coding=utf-8 -*-
> ...

I already mentioned allowing directives in comments to work around
the problem of directive placement before the first doc-string.

The above would then look like this:

#!/usr/local/bin/python
# directive unicodeencoding='utf-8'
u""" UTF-8 doc-string """

The downside of this is that parsing comments breaks the current
tokenizing scheme in Python: the tokenizer removes comments before
passing the tokens to the compiler ...wouldn't be hard to 
fix though ;-) (note that tokenize.py does not)

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/




More information about the Python-list mailing list