xmod


Namexmod JSON
Version 1.8.1 PyPI version JSON
download
home_pagehttps://github.com/rec/xmod
Summary🌱 Turn any object into a module 🌱
upload_time2024-01-04 18:03:17
maintainer
docs_urlNone
authorTom Ritchford
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # 🌱 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](https://rec.github.io/xmod#xmod--api-documentation)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rec/xmod",
    "name": "xmod",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tom Ritchford",
    "author_email": "tom@swirly.com",
    "download_url": "https://files.pythonhosted.org/packages/72/b2/e3edc608823348e628a919e1d7129e641997afadd946febdd704aecc5881/xmod-1.8.1.tar.gz",
    "platform": null,
    "description": "# \ud83c\udf31 Turn any object into a module \ud83c\udf31\n\nCallable modules!  Indexable modules!?\n\nEver wanted to call a module directly, or index it?  Or just sick of seeing\n`from foo import foo` in your examples?\n\nGive your module the awesome power of an object, or maybe just save a\nlittle typing, with `xmod`.\n\n`xmod` is a tiny library that lets a module to do things that normally\nonly a class could do - handy for modules that \"just do one thing\".\n\n## Example: Make a module callable like a function!\n\n    # In your_module.py\n    import xmod\n\n    @xmod\n    def a_function():\n        return 'HERE!!'\n\n\n    # Test at the command line\n    >>> import your_module\n    >>> your_module()\n    HERE!!\n\n## Example: Make a module look like a list!?!\n\n    # In your_module.py\n    import xmod\n\n    xmod(list(), __name__)\n\n    # Test at the command line\n    >>> import your_module\n    >>> assert your_module == []\n    >>> your_module.extend(range(3))\n    >>> print(your_module)\n    [0, 1, 2]\n\n\n### [API Documentation](https://rec.github.io/xmod#xmod--api-documentation)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\ud83c\udf31 Turn any object into a module \ud83c\udf31",
    "version": "1.8.1",
    "project_urls": {
        "Documentation": "https://rec.github.io/xmod",
        "Homepage": "https://github.com/rec/xmod",
        "Repository": "https://github.com/rec/xmod"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "336b0dc75b64a764ea1cb8e4c32d1fb273c147304d4e5483cd58be482dc62e45",
                "md5": "db0f65ef7f5b0955bf30dc8e10055bcb",
                "sha256": "a24e9458a4853489042522bdca9e50ee2eac5ab75c809a91150a8a7f40670d48"
            },
            "downloads": -1,
            "filename": "xmod-1.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db0f65ef7f5b0955bf30dc8e10055bcb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4610,
            "upload_time": "2024-01-04T18:03:16",
            "upload_time_iso_8601": "2024-01-04T18:03:16.078414Z",
            "url": "https://files.pythonhosted.org/packages/33/6b/0dc75b64a764ea1cb8e4c32d1fb273c147304d4e5483cd58be482dc62e45/xmod-1.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "72b2e3edc608823348e628a919e1d7129e641997afadd946febdd704aecc5881",
                "md5": "25ae43b5a9acb60973849fae1fdb5ed5",
                "sha256": "38c76486b9d672c546d57d8035df0beb7f4a9b088bc3fb2de5431ae821444377"
            },
            "downloads": -1,
            "filename": "xmod-1.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "25ae43b5a9acb60973849fae1fdb5ed5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3988,
            "upload_time": "2024-01-04T18:03:17",
            "upload_time_iso_8601": "2024-01-04T18:03:17.663169Z",
            "url": "https://files.pythonhosted.org/packages/72/b2/e3edc608823348e628a919e1d7129e641997afadd946febdd704aecc5881/xmod-1.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-04 18:03:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rec",
    "github_project": "xmod",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "xmod"
}
        
Elapsed time: 0.16396s