Python and unicode

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 19 23:42:30 EDT 2010


On Mon, 20 Sep 2010 09:09:31 +1000, Ben Finney wrote:

> Goran Novosel <goran.novosel at gmail.com> writes:
> 
>> # vim: set encoding=utf-8 :
> 
> This will help Vim, but won't help Python. 

It will actually -- the regex Python uses to detect encoding lines is 
documented, and Vim-style declarations are allowed as are Emacs style. In 
fact, something as minimal as:

# coding=utf-8

will do the job.

> Use the PEP 263 encoding
> declaration <URL:http://www.python.org/dev/peps/pep-0263/> to let Python
> know the encoding of the program source file.

While PEPs are valuable, once accepted or rejected they become historical 
documents. They don't necessarily document the current behaviour of the 
language.

See here for documentation on encoding declarations:

http://docs.python.org/reference/lexical_analysis.html#encoding-declarations



-- 
Steven



More information about the Python-list mailing list