Anything like 'inspect.getsourceencoding()'?

Jeff Epler jepler at
Sun Oct 17 15:35:14 CEST 2004

On Sat, Oct 16, 2004 at 10:30:05PM -0700, Robert Brewer 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.

Python doesn't guess:  it refers to a specially-formatted line that
names the encoding (PEP 263).

It was access to this metadata that I was hoping to find through the
inspect module.

I agree that for general, unknown text files you have to guess. (and
I'll thank myself some day if I save the URL you mentioned)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list