{"id":17093407,"url":"https://github.com/crowsonkb/partial-apply","last_synced_at":"2025-03-23T16:41:18.889Z","repository":{"id":57450888,"uuid":"162354865","full_name":"crowsonkb/partial-apply","owner":"crowsonkb","description":"Partial application of functions and method names, supporting placeholder values for positional arguments.","archived":false,"fork":false,"pushed_at":"2018-12-19T00:46:18.000Z","size":5796,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T16:07:29.979Z","etag":null,"topics":["functional-programming","higher-order-functions","python","python-library"],"latest_commit_sha":null,"homepage":"https://crowsonkb.github.io/partial-apply/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crowsonkb.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-18T22:57:52.000Z","updated_at":"2018-12-19T01:12:02.000Z","dependencies_parsed_at":"2022-09-10T11:02:06.640Z","dependency_job_id":null,"html_url":"https://github.com/crowsonkb/partial-apply","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowsonkb%2Fpartial-apply","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowsonkb%2Fpartial-apply/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowsonkb%2Fpartial-apply/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowsonkb%2Fpartial-apply/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crowsonkb","download_url":"https://codeload.github.com/crowsonkb/partial-apply/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245136112,"owners_count":20566582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","higher-order-functions","python","python-library"],"created_at":"2024-10-14T14:06:52.859Z","updated_at":"2025-03-23T16:41:18.861Z","avatar_url":"https://github.com/crowsonkb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"partial-apply\n=============\n\nPartial application of functions and method names, supporting placeholder values for positional arguments.\n\nUnlike `functools.partial() \u003chttps://docs.python.org/3/library/functools.html#functools.partial\u003e`_, placeholder values are supported so that positional arguments for partial application do not need to be supplied solely from left to right. Keyword arguments are handled equivalently to ``functools.partial()``. It is also possible to \"partially apply\" a method name, producing a function which looks up the method to call on the object supplied as its first argument.\n\n**Dependencies:**\n\n- Python 2.7 or 3.4+.\n\n**Installation:**\n\n- ``$ pip install partial-apply``\n\n**Documentation:**\n\n- Sphinx generated API documentation is available in the ``docs`` subdirectory of this repository and is also published on `GitHub Pages \u003chttps://crowsonkb.github.io/partial-apply/\u003e`_.\n\nExamples\n--------\n\nAn example of placeholder use:\n``````````````````````````````\n\n.. code:: python\n\n   from partial_apply import Empty, PartialFn, PartialMethod\n\n   isint = PartialFn(isinstance, Empty, int)\n\nThis makes a function ``isint()`` that takes one positional argument and returns ``True`` if it is an ``int`` and ``False`` otherwise. That is, calling ``isint(1)`` is equivalent to calling ``isinstance(1, int)``. The supplied positional arguments fill in ``Empty`` placeholder slots from left to right before reverting to ``functools.partial()``-style appending.\n\nAn example of ``PartialMethod`` use:\n````````````````````````````````````\n\n.. code:: python\n\n   count_true = PartialMethod('count', True)\n   count_true((False, True))  # returns 1\n   count_true([False, True])  # returns 1\n\nThis makes a function ``count_true()`` that counts the number of ``True`` values in a sequence. It looks up the sequence method ``count`` on the first argument and calls it with the single argument ``True``. The calls shown are equivalent to ``(False, True).count(True)`` and ``[False, True].count(True)``. Since ``count_true()`` only stores the method name and not the method itself, it works on any type with a ``count()`` method.\n\nLike ``PartialFn``, ``PartialMethod`` supports placeholder positional arguments and ``functools.partial()``-like keyword arguments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowsonkb%2Fpartial-apply","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrowsonkb%2Fpartial-apply","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowsonkb%2Fpartial-apply/lists"}