{ "info": { "author": "Derrick Gilland", "author_email": "dgilland@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "fnc\n***\n\n|version| |travis| |coveralls| |license|\n\n\nFunctional programming in Python with generators and other utilities.\n\n\nLinks\n=====\n\n- Project: https://github.com/dgilland/fnc\n- Documentation: https://fnc.readthedocs.io\n- PyPI: https://pypi.python.org/pypi/fnc/\n- TravisCI: https://travis-ci.org/dgilland/fnc\n\n\nFeatures\n========\n\n- Functional-style methods that work with and return generators.\n- Shorthand-style iteratees (callbacks) to easily filter and map data.\n- String object-path support for references nested data structures.\n- 100% test coverage.\n- Python 3.4+\n\n\nQuickstart\n==========\n\nInstall using pip:\n\n\n::\n\n pip3 install fnc\n\n\nImport the main module:\n\n.. code-block:: python\n\n import fnc\n\n\nStart working with data:\n\n.. code-block:: python\n\n users = [{'id': 1, 'name': 'Jack', 'email': 'jack@example.org', 'active': True},\n {'id': 2, 'name': 'Max', 'email': 'max@example.com', 'active': True},\n {'id': 3, 'name': 'Allison', 'email': 'allison@example.org', 'active': False},\n {'id': 4, 'name': 'David', 'email': 'david@example.net', 'active': False}]\n\n\nFilter active users:\n\n.. code-block:: python\n\n # Uses \"matches\" shorthand iteratee: dictionary\n active_users = fnc.filter({'active': True}, users)\n # \n\n active_uesrs = list(active_users)\n # [{'name': 'Jack', 'email': 'jack@example.org', 'active': True},\n # {'name': 'Max', 'email': 'max@example.com', 'active': True}]\n\n\nGet a list of email addresses:\n\n.. code-block:: python\n\n # Uses \"pathgetter\" shorthand iteratee: string\n emails = fnc.map('email', users)\n # \n\n emails = list(emails)\n # ['jack@example.org', 'max@example.com', 'allison@example.org', 'david@example.net']\n\n\nCreate a ``dict`` of users keyed by ``'id'``:\n\n.. code-block:: python\n\n # Uses \"pathgetter\" shorthand iteratee: string\n users_by_id = fnc.keyby('id', users)\n # {1: {'id': 1, 'name': 'Jack', 'email': 'jack@example.org', 'active': True},\n # 2: {'id': 2, 'name': 'Max', 'email': 'max@example.com', 'active': True},\n # 3: {'id': 3, 'name': 'Allison', 'email': 'allison@example.org', 'active': False},\n # 4: {'id': 4, 'name': 'David', 'email': 'david@example.net', 'active': False}}\n\n\nSelect only ``'id'`` and ``'email'`` fields and return as dictionaries:\n\n.. code-block:: python\n\n # Uses \"pickgetter\" shorthand iteratee: set\n user_emails = list(fnc.map({'id', 'email'}, users))\n # [{'email': 'jack@example.org', 'id': 1},\n # {'email': 'max@example.com', 'id': 2},\n # {'email': 'allison@example.org', 'id': 3},\n # {'email': 'david@example.net', 'id': 4}]\n\n\nSelect only ``'id'`` and ``'email'`` fields and return as tuples:\n\n.. code-block:: python\n\n # Uses \"atgetter\" shorthand iteratee: tuple\n user_emails = list(fnc.map(('id', 'email'), users))\n # [(1, 'jack@example.org'),\n # (2, 'max@example.com'),\n # (3, 'allison@example.org'),\n # (4, 'david@example.net')]\n\n\nAccess nested data structures using object-path notation:\n\n.. code-block:: python\n\n fnc.get('a.b.c[1][0].d', {'a': {'b': {'c': [None, [{'d': 100}]]}}})\n # 100\n\n # Same result but using a path list instead of a string.\n fnc.get(['a', 'b', 'c', 1, 0, 'd'], {'a': {'b': {'c': [None, [{'d': 100}]]}}})\n # 100\n\n\nCompose multiple functions into a generator pipeline:\n\n.. code-block:: python\n\n from functools import partial\n\n filter_active = partial(fnc.filter, {'active': True})\n get_emails = partial(fnc.map, 'email')\n get_email_domains = partial(fnc.map, lambda email: email.split('@')[1])\n\n get_active_email_domains = fnc.compose(filter_active,\n get_emails,\n get_email_domains,\n set)\n\n email_domains = get_active_email_domains(users)\n # {'example.com', 'example.org'}\n\n\nOr do the same thing except using a terser \"partial\" shorthand:\n\n.. code-block:: python\n\n get_active_email_domains = fnc.compose((fnc.filter, {'active': True}),\n (fnc.map, 'email'),\n (fnc.map, lambda email: email.split('@')[1]),\n set)\n\n email_domains = get_active_email_domains(users)\n # {'example.com', 'example.org'}\n\n\nFor more details and examples, please see the full documentation at https://fnc.readthedocs.io.\n\n\n.. |version| image:: https://img.shields.io/pypi/v/fnc.svg?style=flat-square\n :target: https://pypi.python.org/pypi/fnc/\n\n.. |travis| image:: https://img.shields.io/travis/dgilland/fnc/master.svg?style=flat-square\n :target: https://travis-ci.org/dgilland/fnc\n\n.. |coveralls| image:: https://img.shields.io/coveralls/dgilland/fnc/master.svg?style=flat-square\n :target: https://coveralls.io/r/dgilland/fnc\n\n.. |license| image:: https://img.shields.io/pypi/l/fnc.svg?style=flat-square\n :target: https://pypi.python.org/pypi/fnc/\n\nChangelog\n=========\n\n\nv0.4.0 (2019-01-23)\n-------------------\n\n- Add functions:\n\n - ``differenceby``\n - ``duplicatesby``\n - ``intersectionby``\n - ``unionby``\n\n\nv0.3.0 (2018-08-31)\n-------------------\n\n- compose: Introduce new \"partial\" shorthand where instead of passing a callable, a ``tuple`` can be given which will then be converted to a callable using ``functools.partial``. For example, instead of ``fnc.compose(partial(fnc.filter, {'active': True}), partial(fnc.map, 'email'))``, one can do ``fnc.compose((fnc.filter, {'active': True}), (fnc.map, 'email'))``.\n\n\nv0.2.0 (2018-08-24)\n-------------------\n\n- Add functions:\n\n - ``negate``\n - ``over``\n - ``overall``\n - ``overany``\n\n- Rename functions: (**breaking change**)\n\n - ``ismatch -> conforms``\n - ``matches -> conformance``\n\n- Make ``conforms/conformance`` (formerly ``ismatch/matches``) accept callable dictionary values that act as predicates against comparison target. (**breaking change**)\n\n\nv0.1.1 (2018-08-17)\n-------------------\n\n- pick: Don't return ``None`` for keys that don't exist in source object. Instead of ``fnc.pick(['a'], {}) == {'a': None}``, it's now ``fnc.pick(['a'], {}) == {}``.\n\n\nv0.1.0 (2018-08-15)\n-------------------\n\n- First release.\n\nLicense\n=======\n\nThe MIT License (MIT)\n\nCopyright (c) 2018, Derrick Gilland\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dgilland/fnc", "keywords": "fnc functional functional-programming generators utility", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "fnc", "package_url": "https://pypi.org/project/fnc/", "platform": "", "project_url": "https://pypi.org/project/fnc/", "project_urls": { "Homepage": "https://github.com/dgilland/fnc" }, "release_url": "https://pypi.org/project/fnc/0.4.0/", "requires_dist": [ "coverage ; extra == 'dev'", "flake8 ; extra == 'dev'", "pylint ; extra == 'dev'", "pytest ; extra == 'dev'", "pytest-cov ; extra == 'dev'", "Sphinx ; extra == 'dev'", "sphinx-rtd-theme ; extra == 'dev'", "tox ; extra == 'dev'", "twine ; extra == 'dev'", "wheel ; extra == 'dev'" ], "requires_python": "", "summary": "Functional programming in Python with generators and other utilities.", "version": "0.4.0" }, "last_serial": 4732302, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "ee8f795531836b697b5f1cbc0cf0df16", "sha256": "c971c21e052e7c86c606f230a02392fe2f76d1d50e815fead62fc454e8144ae0" }, "downloads": -1, "filename": "fnc-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ee8f795531836b697b5f1cbc0cf0df16", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16333, "upload_time": "2018-08-16T03:10:27", "url": "https://files.pythonhosted.org/packages/8d/1e/4547062ac35c5e14a4406c83986700bab1fcc3a4ff7dc6ea69cfd4dca2ee/fnc-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f26ab8e066064bd050493d6cfa068fab", "sha256": "bd85e82e41fbf402a47a3db39cac5b2235f858fbc5e885b9289caf59873da7d3" }, "downloads": -1, "filename": "fnc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f26ab8e066064bd050493d6cfa068fab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28660, "upload_time": "2018-08-16T03:10:29", "url": "https://files.pythonhosted.org/packages/22/35/09a92a121f57efb583f3837f81f958ca5f0c7ade05d6fd826532ac463cdf/fnc-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "aacf2b47c5cccee892ed5194d03335ba", "sha256": "223f9fd1b93ce3c495ba1df7dc9f8c616d74b8f13f3729fc9a5d37c052f3f021" }, "downloads": -1, "filename": "fnc-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "aacf2b47c5cccee892ed5194d03335ba", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 18520, "upload_time": "2018-08-17T22:52:31", "url": "https://files.pythonhosted.org/packages/dd/c8/c6aba557eba013de0b36d866f753c9ea5d5b1394a011d7a3477492e20d69/fnc-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f99a6d7cc8d965ce3208ced8b6a1191a", "sha256": "4f47b8d8d94b484faa04bd4ca91a7d4f604d69a72ce1b60a22879a40cec3866e" }, "downloads": -1, "filename": "fnc-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f99a6d7cc8d965ce3208ced8b6a1191a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30731, "upload_time": "2018-08-17T22:52:32", "url": "https://files.pythonhosted.org/packages/d5/5c/56b2cfc509c2e679a9d4df0e9bb1085258ce84040b1cd2ae203dd580c269/fnc-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "4611d47f49d9273640ac81f79f95b5ad", "sha256": "f7a578a5bac512231bd7d2b8f7388f113542c22f178015ab16a56e5c9ff6525d" }, "downloads": -1, "filename": "fnc-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "4611d47f49d9273640ac81f79f95b5ad", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19274, "upload_time": "2018-08-24T22:15:27", "url": "https://files.pythonhosted.org/packages/48/d0/40ee25bbc5d0c9b6748c1fbd3ba5f6db5944ec00895fe219bdc8691ccf47/fnc-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2baa9e1c03929c4a36ece2ad2d301f1d", "sha256": "8b0767a693b4e84d7a0678eda824814bc7ddaab26842e2409c8966a95242cf19" }, "downloads": -1, "filename": "fnc-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2baa9e1c03929c4a36ece2ad2d301f1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31805, "upload_time": "2018-08-24T22:15:29", "url": "https://files.pythonhosted.org/packages/b4/a1/9603896871066606f2a79bbc8e1e8af98f73c569951821ee013af1b3fa10/fnc-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "a7c40cdcd5ef8613ea3cb7e40cc536b3", "sha256": "5b767a3f9eb58811d10908d4ff4080d30d927d8c7b2c295b3ae69c7b0cddaf0f" }, "downloads": -1, "filename": "fnc-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a7c40cdcd5ef8613ea3cb7e40cc536b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20028, "upload_time": "2018-08-31T04:16:28", "url": "https://files.pythonhosted.org/packages/4f/59/a23a124b2b63242b1466395fb35d27aecea8f8c897b59c5ba1c48cad850e/fnc-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e7445f9b594e57ddfe90a92e091e5a9", "sha256": "48c8029b14dbe98e3db657ee90af942486c12f899fa0af01a71ac937d5104e75" }, "downloads": -1, "filename": "fnc-0.3.0.tar.gz", "has_sig": false, "md5_digest": "3e7445f9b594e57ddfe90a92e091e5a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32791, "upload_time": "2018-08-31T04:16:29", "url": "https://files.pythonhosted.org/packages/82/18/ea59648b41c6880b863290d61f2e3b107cd1168432a1311d8a3567358a7b/fnc-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "793d03f5fb36a1645fc1ef3997f58eac", "sha256": "1bcd92d2811a8e094914f02155163b0994e0eff510b9ae99b40dbadc7ac2a304" }, "downloads": -1, "filename": "fnc-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "793d03f5fb36a1645fc1ef3997f58eac", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21801, "upload_time": "2019-01-23T17:15:25", "url": "https://files.pythonhosted.org/packages/0c/a4/2eb8986c6d07904b4f82e4e7de6d142cca347b7b70193a3a23ef9a9bdb24/fnc-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ac26bd79ad1812d7c10e415844bc254", "sha256": "8c323cdeb175fb75b39ee31e5f122022ccc8889f30ae71dd4a9186f46fe0ba04" }, "downloads": -1, "filename": "fnc-0.4.0.tar.gz", "has_sig": false, "md5_digest": "0ac26bd79ad1812d7c10e415844bc254", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34183, "upload_time": "2019-01-23T17:15:27", "url": "https://files.pythonhosted.org/packages/0c/e6/3e3b1c755dc2f51e652852f415873422b8c037e2261895b6a5ca69130ed5/fnc-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "793d03f5fb36a1645fc1ef3997f58eac", "sha256": "1bcd92d2811a8e094914f02155163b0994e0eff510b9ae99b40dbadc7ac2a304" }, "downloads": -1, "filename": "fnc-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "793d03f5fb36a1645fc1ef3997f58eac", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21801, "upload_time": "2019-01-23T17:15:25", "url": "https://files.pythonhosted.org/packages/0c/a4/2eb8986c6d07904b4f82e4e7de6d142cca347b7b70193a3a23ef9a9bdb24/fnc-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ac26bd79ad1812d7c10e415844bc254", "sha256": "8c323cdeb175fb75b39ee31e5f122022ccc8889f30ae71dd4a9186f46fe0ba04" }, "downloads": -1, "filename": "fnc-0.4.0.tar.gz", "has_sig": false, "md5_digest": "0ac26bd79ad1812d7c10e415844bc254", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34183, "upload_time": "2019-01-23T17:15:27", "url": "https://files.pythonhosted.org/packages/0c/e6/3e3b1c755dc2f51e652852f415873422b8c037e2261895b6a5ca69130ed5/fnc-0.4.0.tar.gz" } ] }