Anything like 'inspect.getsourceencoding()'?

Just just at xs4all.nl
Sun Oct 17 10:12:13 CEST 2004


In article <mailman.5071.1097991055.5135.python-list at python.org>,
 "Robert Brewer" <fumanchu at amor.org> wrote:

> Jeff Epler wrote:
> > Is there a convenient way to find the encoding of a source file?
> 
> Short answer: no, you have to guess. But check out some good guessing
> algorithms at e.g. http://manatee.mojam.com/~skip/python/decodeh.py

You don't have to guess if the file has a

# -*- coding: encoding -*-

line. Such a line is required anyway, as of Python 2.3, if the source 
file contains non-ascii chars.

Just



More information about the Python-list mailing list