Skip to main content

🌱 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


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.10.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xmod-1.10.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file xmod-1.10.0.tar.gz.

File metadata

  • Download URL: xmod-1.10.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xmod-1.10.0.tar.gz
Algorithm Hash digest
SHA256 b40b2a54d56684b01eb9627892b0c179918e8ef0bd4d7f3bac7a3fdba11cd6e6
MD5 80f35a2d83c60c219fa4ce12ffe196da
BLAKE2b-256 7a3b5a0d2670bab661164e27a5c27c448ae6204458c97cb94ccf89d0c47715bc

See more details on using hashes here.

File details

Details for the file xmod-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: xmod-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xmod-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bebf8493b7ac63097401590a329c9ed20da224de0583a522e7ccb634af122f5a
MD5 5231b207e5b8274cd55c047edaee47d5
BLAKE2b-256 cbe9c362d47ed2b1928d65d61888c1419fae8ef69417fba2067d2fd3da1d400b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page