• Public module interfaces

    From Stefan Ram@21:1/5 to All on Sat Dec 9 10:30:20 2023
    In IDLE, the names of my module A - after it has been imported -
    are sometimes shown for easy selection as a context menu.
    I observed there, that other modules imported by my module A
    also appear there. But those other modules were not intended
    to be part of the public interface provided by my module A.
    To avoid this, I started to import other modules as follows.

    In module A:

    import tkinter as _tkinter

    Now, "_tkinter" is hidden when my module A is being imported.
    So, today I generally use this scheme "import X as _X" everywhere.
    What do you think about this?

    But what about "submodules"? Should I really use constructions as
    the following to prevent them becoming published by my module?

    In module A:

    import tkinter as _tkinter
    import tkinter.messagebox as _tkinter_messagebox
    _tkinter.messagebox = _tkinter_messagebox
    del _tkinter_messagebox

    Now, within my module A, I use "_tkinter.messagebox", and to clients
    of my module A "_tkinter" is not visible.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)