Python and unicode

Peter Otten __peter__ at
Mon Sep 20 12:20:34 CEST 2010

Dotan Cohen wrote:

> On Mon, Sep 20, 2010 at 05:42, Steven D'Aprano
> <steve at> wrote:
>>> Use the PEP 263 encoding
>>> declaration <URL:> 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:
> This is the first time that I've read the PEP document regarding
> Unicode / UTF-8. I see that it mentions that the declaration must be
> on the second or first line of the file. Is this still true in Python
> 3? 


> I have been putting it further down (still before all python code,
> but after some comments) in code that I write (for my own use, not
> commercial code).

It may work by accident, if you declare it as UTF-8, because that is also 
the default in Python 3.


More information about the Python-list mailing list