Skip to main content

module_to_dict

Convert a module namespace to a Python dictionary.

def module_to_dict(
module: module,
omittable: callable = lambda k: k.startswith("_") or not k.isupper()
) - > dict

Convert a module namespace to a Python dictionary.

Parameters

NameTypeDescription
modulemoduleThe Python module object whose namespace attributes will be extracted.
omittablecallable = lambda k: k.startswith("_") or not k.isupper()A predicate function that takes an attribute name and returns True if the attribute should be excluded from the resulting dictionary.

Returns

TypeDescription
dictA dictionary mapping attribute names to their string representations (via repr), containing only the non-omitted members of the module.