ambiguous


Nameambiguous JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
Summaryflexibility when you need it
upload_time2024-06-26 04:34:09
maintainerNone
docs_urlNone
authorDaniel Pepper
requires_python>=3
licenseThe MIT License (MIT) Copyright (c) 2018 Daniel Pepper Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ambiguous
======
flexibility when you need it


### Install
```bash
pip install ambiguous
```


### Usage

#### decorator: allow decorators to accept arguments
```python
from ambiguous import decorator


@decorator
def power(fn, exponent=2):
  '''take function results and raise to an exponent'''
  return lambda x: fn(x) ** exponent


@power
def squared(x): return x

squared(2)
> 4


@power(exponent=3)
def cubed(x): return x

cubed(2)
> 8
```

#### thing_or_things: combine gets and multigets

```python
from ambiguous import thing_or_things

@thing_or_things
def itself(args):
  return { x : x for x in args }

itself(1)
> 1
itself([1, 2])
> { 1 : 1, 2 : 2 }


# specify which argument
@thing_or_things('args')
def prefix(prefix, args):
  return { x : "%s_%s" % (prefix, x) for x in args }

prefix('abc', [1, 2])
> { 1 : 'abc_1', 2 : 'abc_2' }
```


#### optional parentheses  (warning: still experimental)
```python
import ambiguous

@ambiguous
def foo():
  return 'foo'

# the usual
foo()
> 'foo'

# ?!?
foo
> 'foo'
foo + 'abc'
> 'fooabc'
```

----
[![installs](https://img.shields.io/pypi/dm/ambiguous.svg?label=installs)](https://pypi.org/project/ambiguous)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ambiguous",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": null,
    "author": "Daniel Pepper",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fa/34/ac4555e0f1a6c0353d33347e8bff449347bdd30476ef54d2efde08d2c96b/ambiguous-0.5.0.tar.gz",
    "platform": null,
    "description": "ambiguous\n======\nflexibility when you need it\n\n\n### Install\n```bash\npip install ambiguous\n```\n\n\n### Usage\n\n#### decorator: allow decorators to accept arguments\n```python\nfrom ambiguous import decorator\n\n\n@decorator\ndef power(fn, exponent=2):\n  '''take function results and raise to an exponent'''\n  return lambda x: fn(x) ** exponent\n\n\n@power\ndef squared(x): return x\n\nsquared(2)\n> 4\n\n\n@power(exponent=3)\ndef cubed(x): return x\n\ncubed(2)\n> 8\n```\n\n#### thing_or_things: combine gets and multigets\n\n```python\nfrom ambiguous import thing_or_things\n\n@thing_or_things\ndef itself(args):\n  return { x : x for x in args }\n\nitself(1)\n> 1\nitself([1, 2])\n> { 1 : 1, 2 : 2 }\n\n\n# specify which argument\n@thing_or_things('args')\ndef prefix(prefix, args):\n  return { x : \"%s_%s\" % (prefix, x) for x in args }\n\nprefix('abc', [1, 2])\n> { 1 : 'abc_1', 2 : 'abc_2' }\n```\n\n\n#### optional parentheses  (warning: still experimental)\n```python\nimport ambiguous\n\n@ambiguous\ndef foo():\n  return 'foo'\n\n# the usual\nfoo()\n> 'foo'\n\n# ?!?\nfoo\n> 'foo'\nfoo + 'abc'\n> 'fooabc'\n```\n\n----\n[![installs](https://img.shields.io/pypi/dm/ambiguous.svg?label=installs)](https://pypi.org/project/ambiguous)\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2018 Daniel Pepper  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "flexibility when you need it",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/dpep/py_ambiguous"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "417f99905cc12a3e8bd0a5172acfa1708a789b2c6fb57403f1f98cf1c15663d7",
                "md5": "acbf15ccccf5673df2dc35d5b56628ca",
                "sha256": "c4ea535362e95f0032521dc33a89d549d24208cf88988ad06d5de8f3fdc263e4"
            },
            "downloads": -1,
            "filename": "ambiguous-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acbf15ccccf5673df2dc35d5b56628ca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 7181,
            "upload_time": "2024-06-26T04:34:07",
            "upload_time_iso_8601": "2024-06-26T04:34:07.791286Z",
            "url": "https://files.pythonhosted.org/packages/41/7f/99905cc12a3e8bd0a5172acfa1708a789b2c6fb57403f1f98cf1c15663d7/ambiguous-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa34ac4555e0f1a6c0353d33347e8bff449347bdd30476ef54d2efde08d2c96b",
                "md5": "2d6e309db44008fc7e88f7a5a8f547f0",
                "sha256": "2c5d9b89c5cb04a186265ba3796b9e3d429ca6d01a942939382d90f7106fc63e"
            },
            "downloads": -1,
            "filename": "ambiguous-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2d6e309db44008fc7e88f7a5a8f547f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 10865,
            "upload_time": "2024-06-26T04:34:09",
            "upload_time_iso_8601": "2024-06-26T04:34:09.252574Z",
            "url": "https://files.pythonhosted.org/packages/fa/34/ac4555e0f1a6c0353d33347e8bff449347bdd30476ef54d2efde08d2c96b/ambiguous-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-26 04:34:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dpep",
    "github_project": "py_ambiguous",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ambiguous"
}
        
Elapsed time: 3.89001s