Anything like 'inspect.getsourceencoding()'?
Maciej Dziardziel
fiedzia at fiedzia.prv.pl
Sun Oct 17 04:40:56 EDT 2004
Jeff Epler wrote:
> Is there a convenient way to find the encoding of a source file? I
> thought maybe this would be in the inspect module, but I didn't see it
> there. Just as nice would be a way to get the file as a unicode string,
> I suppose.
>
> (This is related to another thread I've recently posted to, where
> another user was having trouble with pydoc's links to source files using
> the file: protocol. I suggested having pydoc serve the source files,
> and provided a patch, but it's crossed my mind that it would be nice to
> tell the browser the encoding of that file.
>
> Jeff
According to Python documentation:
It is possible to use encodings different than ASCII in Python source files.
The best way to do it is to put one more special comment line right after
the #! line to define the source file encoding:
# -*- coding: iso-8859-1 -*-
--
Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
www.fiedzia.prv.pl
How can you be ALONE with somebody? Think about it...
More information about the Python-list
mailing list