[Python-Dev] module customization

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 16 01:11:56 EST 2017


Ethan Furman wrote:
> The second way is fairly similar, but instead of replacing the entire 
> sys.modules entry, its class is updated to be the class just created -- 
> something like sys.modules['mymod'].__class__ = MyNewClass .

If the recent suggestion to replace the global namespace
dict with the module object goes ahead, maybe it would enable
using this idiom to reassign the module class:

    class __class__(__class__):
       # module methods here

Badger-badger-badger-ly,
Greg


More information about the Python-Dev mailing list