[Python-ideas] Add 'module' module, similar to 'keyword' module

Guido van Rossum guido at python.org
Fri Oct 30 21:19:54 EDT 2015


There's sys.builtin_module_names which returns the names of the hardcoded
builtin modules. Dynamically loaded modules can be found by searching
sys.path in the usual way -- importlib shoul know. I wonder if just asking
importlib whether it can locate a given module would be enough?

On Fri, Oct 30, 2015 at 6:09 PM, Terry Reedy <tjreedy at udel.edu> wrote:

> 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
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151030/124d7091/attachment.html>


More information about the Python-ideas mailing list