Le dimanche 10 septembre 2006 à 14:52 +0100, David Hopwood a écrit :
> > On the other hand "autotextfile('myfile.txt', by_content=True)" would
> > enable content-based guessing, thus be equivalent to Paul's
> > "encoding='guess'".
> 
> As I pointed out earlier, any file open function that guesses the encoding
> should return which encoding has been guessed.

Since open files are objects, the encoding can just be a read-only
property:

# replace autotextfile by whatever API is finally chosen ;)
f = autotextfile('myfile.txt', by_content=True)
enc = f.encoding

> Alternatively, it could be possible to allow the encoding to be set
> after the file has been opened, in which case a separate function
> could do the guessing.

Yes, sounds like a nice alternative.

Regards

Antoine.


_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to