xmod

🌱 Turn any object into a module 🌱

22 个版本 Python >=3.10
安装
pip install xmod
poetry add xmod
pipenv install xmod
conda install xmod
描述

🌱 Turn any object into a module 🌱

Callable modules! Indexable modules!?

Ever wanted to call a module directly, or index it? Or just sick of seeing from foo import foo in your examples?

Give your module the awesome power of an object, or maybe just save a little typing, with xmod.

xmod is a tiny library that lets a module to do things that normally only a class could do - handy for modules that "just do one thing".

Example: Make a module callable like a function!

# In your_module.py
import xmod

@xmod
def a_function():
    return 'HERE!!'


# Test at the command line
>>> import your_module
>>> your_module()
HERE!!

Example: Make a module look like a list!?!

# In your_module.py
import xmod

xmod(list(), __name__)

# Test at the command line
>>> import your_module
>>> assert your_module == []
>>> your_module.extend(range(3))
>>> print(your_module)
[0, 1, 2]

API Documentation

版本列表
1.10.0 2026-05-09
1.9.0 2026-02-03
1.8.1 2024-01-04
1.8.0 2023-12-29
1.7.2 2023-12-28
1.7.1 2023-12-28
1.7.0 2023-12-28
1.6.1 2023-12-28
1.6.0 2023-10-05
1.5.0 2023-07-09
1.4.0 2023-02-25
1.3.2 2022-06-06
1.3.1 2022-06-06
1.3.0 2020-12-01
1.2.1 2020-11-17
1.2.0 2020-11-16
1.1.3 2020-11-14
1.1.2 2020-10-08
1.1.1 2020-09-02
1.1.0 2020-07-26
1.0.1 2020-07-22
1.0.0 2020-07-18