[Python-Dev] Improve open() to support reading file starting with an unicode BOM

Guido van Rossum guido at python.org
Fri Jan 8 16:54:15 CET 2010

On Fri, Jan 8, 2010 at 6:34 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Victor Stinner <victor.stinner <at> haypocalc.com> writes:
>> I wrote a new version of my patch (version 3):
>>  * don't change the default behaviour: use open(filename, encoding="BOM") to
>> check the BOM is there is any
> Well, I think if we implement this the default behaviour *should* be changed.
> It looks a bit senseless to have two different "auto-choose" options, one with
> encoding=None and one with encoding="BOM".

Well there *are* two different auto options: use the environment
variables (LANG etc.) or inspect the contents of the file. I think it
would be useful to have ways to specify both.

--Guido van Rossum (python.org/~guido)

More information about the Python-Dev mailing list