[issue10335] tokenize.open_python(): open a Python file with the right encoding

STINNER Victor report at bugs.python.org
Sun Nov 7 10:04:49 CET 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> what about open(.., encoding="fromcookie")?

Please don't do that. It remembers me the magical str.encode() method of 
Python2. I prefer simple API with limited features: if you want to open a 
Python script, use tokenize.open(), if you want to open an XML document use 
any XML library, etc. It remembers me also the discussion about detecting BOM 
in text files: issue #7651. There was no consensus, and so the issue is still 
open.

For this particular issue, I prefer a specific function tokenize.<choose a 
function name>.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10335>
_______________________________________


More information about the Python-bugs-list mailing list