[Python-3000] encoding='guess' ?
solipsis at pitrou.net
Sun Sep 10 16:00:06 CEST 2006
Le dimanche 10 septembre 2006 à 23:44 +1000, Nick Coghlan a écrit :
> Interesting. This goes back more towards the model of "no default encoding,
> but provide the right tools to make it easy for a program to choose one in the
> absence of any metadata".
In the "clean" API yes.
But it would be nice to also have an easy API for small scripts, hence
my "autotextfile" proposal.
(and, it would also avoid making life too hard for beginners trying to
learn the language)
> f = open(fname, 'r', string.guessencoding(fname))
This one is inefficient because it results in opening the file twice:
once in string.guessencoding(), and once in open().
This does not happen if there is a special argument instead, like
"by_content=True" in my proposal.
More information about the Python-3000