[Python-ideas] Add 'module' module, similar to 'keyword' module
Terry Reedy
tjreedy at udel.edu
Fri Oct 30 21:09:00 EDT 2015
This idea results from issue of user files shadowing stdlib files on
import. There was a thread on pydev about this yesterday. There is
also an opposite issue of builtin modules shadowing user files.
The keyword module provides kwlist and iskeyword function. One use of
kwlist is used in some other stdlib modules and can be used by syntax
highlighters (as in IDLE). Kwlist is updated by the main function.
A module module would have at least liblist and islibmodule function.
Liblist would contain all directories with __init__.py and all .py
files. (I don't think files within package directories should be
included, as there is no direct shadowing problem.) A python oriented
editor could then warn on save requests "This name matches a stdlib name
in /Lib. If you run python in this directory, you will not be able to
import the stdlib module. Continue?".
The module should also have binlist and isbinmodule for builtin modules.
(I do not know how to get such a list. If necessary, an api could be
added.) An editor could than warn "This name matches a builtin stdlib
name. You will not be able to import this file. Continue?".
--
Terry Jan Reedy
More information about the Python-ideas
mailing list