[Python-ideas] Python 3 open() text files: make encoding parameter optional for cross-platform scripts

Oleg Broytman phd at phdru.name
Mon Jun 10 00:20:10 CEST 2013


On Sun, Jun 09, 2013 at 02:52:32PM -0700, Andrew Barnert <abarnert at yahoo.com> wrote:
> There's definitely a case to be made for implementing some kind of Notepad-like heuristics in Python. It would be great to be able to do this at the interactive interpreter:
> 
> line = text.partition('\n')[0]
> for encoding in codecs.guess(text)[:10]:
>     print(encoding, line.decode(encoding))
> 
> In fact, if you wrote that at pushed it to PyPI I'd start using it today, and maybe even lobbying for its inclusion in the stdlib.

   Chardet (and variants)?
https://pypi.python.org/pypi?%3Aaction=search&term=chardet&submit=search

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-ideas mailing list