{"id":21891225,"url":"https://github.com/deathbeds/poser","last_synced_at":"2025-04-15T13:48:43.457Z","repository":{"id":57454257,"uuid":"119312109","full_name":"deathbeds/poser","owner":"deathbeds","description":"dysfunctional programming in python ","archived":false,"fork":false,"pushed_at":"2022-10-21T18:03:02.000Z","size":18709,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:45:45.051Z","etag":null,"topics":["composition","functional-programming","python","syntactic-sugar"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deathbeds.png","metadata":{"files":{"readme":"readme.md","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-01-29T00:40:08.000Z","updated_at":"2023-04-14T14:19:22.000Z","dependencies_parsed_at":"2022-09-04T19:10:30.152Z","dependency_job_id":null,"html_url":"https://github.com/deathbeds/poser","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deathbeds%2Fposer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deathbeds%2Fposer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deathbeds%2Fposer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deathbeds%2Fposer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deathbeds","download_url":"https://codeload.github.com/deathbeds/poser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248553782,"owners_count":21123519,"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":["composition","functional-programming","python","syntactic-sugar"],"created_at":"2024-11-28T12:23:32.996Z","updated_at":"2025-04-15T13:48:43.431Z","avatar_url":"https://github.com/deathbeds.png","language":"Python","readme":"\nimport toolz\nimport poser\nfrom poser import λ, Λ, stars\n[![Github Actions](https://github.com/deathbeds/poser/workflows/Python % 20package/badge.svg)](https: // github.com/deathbeds/poser/actions)\n[![PyPI version](https://badge.fury.io/py/poser.svg)](https: // badge.fury.io/py/poser)\n[![Binder](https://mybinder.org/badge_logo.svg)](https: // mybinder.org/v2/gh/deathbeds/poser/master)\n\n\na functional swiss army knife for python. `poser` provides python objects you didn't know you needed.\n\n\n# Be a `poser`\n\n`poser` is a API for lazy, (dys)functional python programming. It allows complex functions to be composed using fluent or symbollic interfaces.\n\n```bash\npip install poser\n```\n\n\u003e _dysfunctional programming_ == = Functional programming with all the side effects.\n\nNew to[functional programming]? Functional programming uses declarative functions to compose complex operations on arguments.\nIf you are familiar with python then[`toolz`][toolz] is a great starting point, [`poser`][poser] is a compact[API] for [`toolz`] and the python\n[standard library].\n\n`poser`\n\n# `poser` API\n\n\n`λ` is a composition that always returns a function. For example, below we create a list of numbers from 1 to a some value\n\n\u003e\u003e \u003e f = λ.range(1).list()\nf\n    λ(\u003c class 'list' \u003e , functools.partial( \u003c class 'range' \u003e , 1))\n    \u003e\u003e \u003e assert callable(f)\n    \u003e\u003e \u003e f(5), f(10)\n    ([1, 2, 3, 4], [1, 2, 3, 4, 5, 6, 7, 8, 9])\n\n`poser` can use forward references to lazily import modules.\n\n\u003e\u003e \u003e g = λ.range(1).enumerate().dict()['pandas.Series']\ng\n    λ(ForwardRef('pandas.Series'), \u003c class 'dict' \u003e , \u003c class 'enumerate' \u003e , functools.partial(\u003c class 'range' \u003e , 1))\n    \u003e\u003e \u003e λ(9) + g + type + ...\n    \u003cclass 'pandas.core.series.Series' \u003e\n\n\n`Λ` is for object function composition where the\nfunction represents symbollic or chained methods\n\n\u003e\u003e \u003e (Λ*10+2)(1)\n12\n\u003e\u003e \u003e assert (Λ*10+2)(1) == 1*10+2\n\u003e\u003e \u003e s = \"A formatted string :{}: with a %s\"\n... (Λ.format('foo') % '% formatted').upper()(s)\n'A FORMATTED STRING :FOO: WITH A % FORMATTED'\n\n\u003e\u003e \u003e assert (Λ.format('foo') % '% formatted').upper()(s)\\\n    ... == (s.format('foo') % '% formatted').upper()\n\nThe `poser` API expresses all of the symbols in the python data model.  Refer to the tests for examples.\n\n# juxtaposition\n\n\u003e\u003e \u003e assert isinstance(λ[range, type, str](10), tuple)\n\u003e\u003e \u003e assert isinstance(λ[[range, type, str]](10), list)\n\u003e\u003e \u003e assert isinstance(λ[{range, type, str}](10), set)\n\nValue and keyword functions can be supplied to juxtapose functions across dictionaries.\n\nλ[{'a': range, type: str}](10)\n{'a': range(0, 10), int: '10'}\n\n\n# Example recipes.\n\nget = λ['functools.lru_cache']()(\n    λ['requests.get'][λ[Λ.json()] ^ BaseException | Λ.text()])\nget\n\nread = λ**Λ.startswith('http') \u0026 get | λ.Path().read_text()\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeathbeds%2Fposer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeathbeds%2Fposer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeathbeds%2Fposer/lists"}