whatever


Namewhatever JSON
Version 0.7 PyPI version JSON
download
home_pagehttp://github.com/Suor/whatever
SummaryEasy way to make anonymous functions by partial application of operators.
upload_time2023-01-29 09:50:31
maintainer
docs_urlNone
authorAlexander Schepanovski
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            The Whatever Object
===================

An easy way to make lambdas by partial application of python operators.

Inspired by Perl 6 one, see http://perlcabal.org/syn/S02.html#The_Whatever_Object


Usage
-----

.. code:: python

    from whatever import _, that

    # get a list of guys names
    names = map(_.name, guys)
    names = map(that.name, guys)

    odd = map(_ * 2 + 1, range(10))

    squares = map(_ ** 2, range(100))
    small_squares = filter(_ < 100, squares)

    best = max(tries, key=_.score)
    sort(guys, key=-that.height)

    factorial = lambda n: reduce(_ * _, range(2, n+1))

NOTE: chained comparisons cannot be implemented since there is no boolean overloading in python.


CAVEATS
-------

In some special cases whatever can cause confusion:

.. code:: python

    _.attr # this makes callable
    obj._  # this fetches '_' attribute of obj

    _[key] # this works too
    d[_]   # KeyError, most probably

    _._    # short for attrgetter('_')
    _[_]   # short for lambda d, k: d[k]

    if _ == 'Any value':
        # You will get here, definitely
        # `_ == something` produces callable, which is true

    [1, 2, _ * 2, None].index('hi') # => 2, since bool(_ * 2 == 'hi') is True


Also, whatever sometimes fails on late binding:

.. code:: python

    (_ * 2)('2') # -> NotImplemented

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/Suor/whatever",
    "name": "whatever",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Alexander Schepanovski",
    "author_email": "suor.web@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/13/d8/e640240bc42f78846b691b16d66591e4fde0c3db7a3dd1085cd82b3130a8/whatever-0.7.tar.gz",
    "platform": null,
    "description": "The Whatever Object\n===================\n\nAn easy way to make lambdas by partial application of python operators.\n\nInspired by Perl 6 one, see http://perlcabal.org/syn/S02.html#The_Whatever_Object\n\n\nUsage\n-----\n\n.. code:: python\n\n    from whatever import _, that\n\n    # get a list of guys names\n    names = map(_.name, guys)\n    names = map(that.name, guys)\n\n    odd = map(_ * 2 + 1, range(10))\n\n    squares = map(_ ** 2, range(100))\n    small_squares = filter(_ < 100, squares)\n\n    best = max(tries, key=_.score)\n    sort(guys, key=-that.height)\n\n    factorial = lambda n: reduce(_ * _, range(2, n+1))\n\nNOTE: chained comparisons cannot be implemented since there is no boolean overloading in python.\n\n\nCAVEATS\n-------\n\nIn some special cases whatever can cause confusion:\n\n.. code:: python\n\n    _.attr # this makes callable\n    obj._  # this fetches '_' attribute of obj\n\n    _[key] # this works too\n    d[_]   # KeyError, most probably\n\n    _._    # short for attrgetter('_')\n    _[_]   # short for lambda d, k: d[k]\n\n    if _ == 'Any value':\n        # You will get here, definitely\n        # `_ == something` produces callable, which is true\n\n    [1, 2, _ * 2, None].index('hi') # => 2, since bool(_ * 2 == 'hi') is True\n\n\nAlso, whatever sometimes fails on late binding:\n\n.. code:: python\n\n    (_ * 2)('2') # -> NotImplemented\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Easy way to make anonymous functions by partial application of operators.",
    "version": "0.7",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "752b3ae9940b7e3a368160ba183aa97d0493b803da3f73dd46bb9808be0314eb",
                "md5": "ffc0216738eea7d71e2942cb182ad3de",
                "sha256": "4a862efbb11a88e9b162e88a59a5eb8b1e656df6c39c6e818f7902bf1d27d728"
            },
            "downloads": -1,
            "filename": "whatever-0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ffc0216738eea7d71e2942cb182ad3de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5267,
            "upload_time": "2023-01-29T09:50:29",
            "upload_time_iso_8601": "2023-01-29T09:50:29.075613Z",
            "url": "https://files.pythonhosted.org/packages/75/2b/3ae9940b7e3a368160ba183aa97d0493b803da3f73dd46bb9808be0314eb/whatever-0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "13d8e640240bc42f78846b691b16d66591e4fde0c3db7a3dd1085cd82b3130a8",
                "md5": "dcea2d2be8701b0f6d0f821617b2c4fd",
                "sha256": "82d9ab46297c41e2fd4947684f666d4f06c632edd458caf4468417da51c84581"
            },
            "downloads": -1,
            "filename": "whatever-0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "dcea2d2be8701b0f6d0f821617b2c4fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6921,
            "upload_time": "2023-01-29T09:50:31",
            "upload_time_iso_8601": "2023-01-29T09:50:31.361225Z",
            "url": "https://files.pythonhosted.org/packages/13/d8/e640240bc42f78846b691b16d66591e4fde0c3db7a3dd1085cd82b3130a8/whatever-0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-29 09:50:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Suor",
    "github_project": "whatever",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "whatever"
}
        
Elapsed time: 0.09972s