Valid encodings for a Python source file

Daniel Glus danielhglus at gmail.com
Thu Jun 7 16:40:20 EDT 2018


I'm trying to figure out the entire list of possible encodings for a Python
source file - that is, encodings that can go in a PEP 263
<https://www.python.org/dev/peps/pep-0263/> encoding specification, like #
-*- encoding: foo -*-.

Is this list the same as the list given in the documentation for the codecs
library, under "Standard Encodings"
<https://docs.python.org/3.6/library/codecs.html#standard-encodings>? If
not, where can I find the actual list?

(I know that list is the same as the set of unique values in CPython's
/Lib/encodings/aliases.py
<https://github.com/python/cpython/blob/master/Lib/encodings/aliases.py>,
or equivalently, the set of filenames in /Lib/encodings/
<https://github.com/python/cpython/blob/master/Lib/encodings/>, but again
I'm not sure.)
-Daniel



More information about the Python-list mailing list