🌱 Turn any object into a module 🌱
Project description
🌱 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xmod-1.8.1.tar.gz
(4.0 kB
view details)
Built Distribution
xmod-1.8.1-py3-none-any.whl
(4.6 kB
view details)
File details
Details for the file xmod-1.8.1.tar.gz
.
File metadata
- Download URL: xmod-1.8.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38c76486b9d672c546d57d8035df0beb7f4a9b088bc3fb2de5431ae821444377 |
|
MD5 | 25ae43b5a9acb60973849fae1fdb5ed5 |
|
BLAKE2b-256 | 72b2e3edc608823348e628a919e1d7129e641997afadd946febdd704aecc5881 |
File details
Details for the file xmod-1.8.1-py3-none-any.whl
.
File metadata
- Download URL: xmod-1.8.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a24e9458a4853489042522bdca9e50ee2eac5ab75c809a91150a8a7f40670d48 |
|
MD5 | db0f65ef7f5b0955bf30dc8e10055bcb |
|
BLAKE2b-256 | 336b0dc75b64a764ea1cb8e4c32d1fb273c147304d4e5483cd58be482dc62e45 |