Comment on draft PEP for deprecating six builtins
Alex Martelli
aleax at aleax.it
Mon Apr 29 03:48:47 EDT 2002
Martin v. Löwis wrote:
...
>> 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
...
> 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.
Right -- "import" can indeed "execute arbitrary stuff". So, one way
to do the "minor extension" I was musing about would be to provide
suitable modules (perhaps a package) for the typical compatibility
needs related to builtins being deprecated or moved away. Although
it appears to me that having the PTH file accept "from x import y,z"
and implicitly execute that in __builtin__.__dict__ might be more
direct and immediate for people who write .PTH files.
Alex
More information about the Python-list
mailing list