[Python-Dev] Re: [Zope3-dev] Zip import and sys.path manipulation (was Re: directory hierarchy proposal)
Martin v. Löwis
martin@v.loewis.de
17 Dec 2002 23:11:36 +0100
Guido van Rossum <guido@python.org> writes:
> - Nobody remembers why there is a special case in site.py for lines in
> the .pth file that start with 'import', except that Martin von
> Loewis once wanted this.
It serves the deployment of packages: you can have code that is run
from site.py, by just installing a file. This is much simpler than,
say, modifying sitecustomize.
I specifically wanted this to register new codecs, and, to some
degree, it is used for that. The Korean codecs package ships a PTH
file that says
import korean.aliases
korean/aliases.py starts with
import encodings.aliases
encodings.aliases.aliases.update({
'cp949': 'korean.cp949',
'ms949': 'korean.cp949',
'uhc': 'korean.cp949',
'euc_kr': 'korean.euc_kr',
...
Adding new codecs or new aliases is very similar to adding new items
to sys.path. I guess you can also use it to register new importers,
if Just's future PEP is accepted.
Regards,
Martin