I am writing a Python module that has only about 20 interesting types and global methods, but many constants and exceptions (about 70 constants for locales, 60 constants for encodings, 20 formatting attributes, more than 200 exceptions, etc. on). As a result, help() on this module produces about 16,000 lines of text and is dotted with almost identical descriptions of each exception. Constants are not so demanding, but they are still hard to navigate.
What would be the pythonic way to organize such a module? Just leave it as it is and rely on other documentation? Move constants to separate dicts? Into submodules? Add them as class level constants, where appropriate?
Note that this is a C extension, so I cannot easily add a real submodule here. I heard that sys.modules does not actually check if the object has a module, so you can add dictionaries there; that way, I could create mymodule.locales , mymodule.encoding and mymodule.exceptions and add them to sys.modules when my module is imported. Will this be a good idea or is it too hacky?
source share