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

Terry Reedy tjreedy at udel.edu
Sat Oct 31 01:56:33 EDT 2015


On 10/30/2015 9:19 PM, Guido van Rossum wrote:
> There's sys.builtin_module_names which returns the names of the
> hardcoded builtin modules.

Great.  With this solved, I opened an issue for IDLE.
https://bugs.python.org/issue25522

> 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?

The default search order is stdlib builtins, local user files, /lib 
files, so the shadowing issue the opposite for builtin and /lib modules. 
  Hence a different message is needed.

> On Fri, Oct 30, 2015 at 6:09 PM, Terry Reedy
> <tjreedy at udel.edu
> <mailto: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
>     <mailto: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 <http://python.org/~guido>)
>
>
> _______________________________________________
> 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/
>


-- 
Terry Jan Reedy



More information about the Python-ideas mailing list