Anything like 'inspect.getsourceencoding()'?

Jeff Epler jepler at unpythonic.net
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. http://manatee.mojam.com/~skip/python/decodeh.py

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)

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041017/0072101d/attachment.pgp>


More information about the Python-list mailing list