Comment on draft PEP for deprecating six builtins

Martin v. Löwis loewis at informatik.hu-berlin.de
Mon Apr 29 03:14:19 EDT 2002


Alex Martelli <aleax at aleax.it> writes:

> I think a finer-grained mechanism might be preferable, and handled by
> site.py / siteconfigure.py, perhaps, much like today are handles such
> issues as sys.path normalization, and Unicode default-encoding.  The
> former may be a more successful example than the latter, so maybe the
> need might be best approached via an extension to the parsing and
> handling of .PTH files.
> 
> Right now, .PTH files handle importing and path-setting needs of
> installed packages.  Having them handle such packages' builtins-needs
> as well seems a minor extension.

The current .PTH design allows for that kind of operation already:

# functional_compat.py
import __builtin__
exec "from functional import map,filter,reduce" in __builtin__.__dict__

# functional_compat.pth
import functional_compat

Alternatively, you could install a single .pth file enabling several
compatibility features:

# Numeric.pth
Numeric
Numeric/more_stuff
import functional_compat
import pow_compat

My original intention was that those import lines in .pth files can
install Unicode codecs in the codecs registry, but they, of course,
all for the execution of arbitrary stuff.

HTH,
Martin



More information about the Python-list mailing list