Xmod is a tiny Python library designed to transform any Python object into a module. This allows for modules to be callable, indexable, or to expose an object's methods and properties directly, reducing boilerplate code. It is currently at version 1.9.0 (released February 3, 2026) and maintains an active development status with frequent minor updates and dependency bumps.
pip install xmodVerified import paths — ran on the pinned version, not inferred.
The most common usage is to decorate a function within a module to make the module itself callable. This example demonstrates making the module 'your_module' callable, returning a greeting.
For typical module extension, ensure `xmod(..., name=__name__)` is used. Only deviate if you have an advanced use case requiring specific `sys.modules` manipulation.
If an exception related to `functools.partial` is raised, adjust your approach as indicated by the error message. Consider alternative partial application techniques or consult `xmod`'s documentation for compatible patterns.
Be selective about attribute exposure; prefer `full=False` and explicitly expose only what's necessary. Understand the implications of mutable module state before setting `mutable=True` and favor immutable extensions where possible.
pip install xmod
Use `from xmod import xmod` to import the function directly, or call it as `xmod.xmod(my_object)` if you only imported `xmod`.
Ensure the attribute or method exists on the object passed to `xmod.xmod()`, or check for typos when accessing it through the `xmod`-generated module.
Only call the `xmod`-generated module directly if the object it wraps is callable (has a `__call__` method). Otherwise, access its attributes or methods, e.g., `my_module.some_method()`.
No dependency data recorded yet.