Anything like 'inspect.getsourceencoding()'?
fumanchu at amor.org
Sun Oct 17 21:29:34 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.
Ah, thanks. I wasn't reading "source file" as "Python module".
More information about the Python-list