{"id":16199288,"url":"https://github.com/j6k4m8/fonc","last_synced_at":"2025-07-27T18:03:41.717Z","repository":{"id":57431799,"uuid":"294510677","full_name":"j6k4m8/fonc","owner":"j6k4m8","description":"multiline anonymous lambda functions in Python","archived":false,"fork":false,"pushed_at":"2022-02-16T19:13:49.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T19:46:38.817Z","etag":null,"topics":["anonymous-functions","code-sin","lambda-functions","mayonnaise-toothpaste","python","sin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j6k4m8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-10T20:03:27.000Z","updated_at":"2022-02-16T19:13:53.000Z","dependencies_parsed_at":"2022-09-02T12:40:18.864Z","dependency_job_id":null,"html_url":"https://github.com/j6k4m8/fonc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j6k4m8%2Ffonc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j6k4m8%2Ffonc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j6k4m8%2Ffonc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j6k4m8%2Ffonc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j6k4m8","download_url":"https://codeload.github.com/j6k4m8/fonc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247700870,"owners_count":20981833,"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":["anonymous-functions","code-sin","lambda-functions","mayonnaise-toothpaste","python","sin"],"created_at":"2024-10-10T09:24:56.618Z","updated_at":"2025-04-07T17:41:57.133Z","avatar_url":"https://github.com/j6k4m8.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fonc\n\n[![PyPI](https://img.shields.io/pypi/v/fonc?style=for-the-badge)](https://pypi.org/project/fonc)\n[![not good](https://img.shields.io/badge/it%20is%20bad-%F0%9F%91%8E-blue?style=for-the-badge)](https://github.com/j6k4m8/fonc)\n\nmultiline inline anonymous functions in python\n\n```shell\npip install fonc\n# rejoice\n```\n\n---\n\n```python\n\u003e\u003e\u003e from fonc import fonc\n\u003e\u003e\u003e [\n...     fonc(\"\"\"\n... def x(input): # doesn't matter what this function is called\n...     value = input * 3.14\n...     return int(value)\n...     \"\"\")(value) for value in [1, 2, 3, 4]\n... ]\n[3, 6, 9, 12]\n```\n\n## why would you do this terrible thing\n\n:) :) :) :) :) :) :) :) :) :) :) :)\n\n## does this pollute my global namespace?\n\nnope!\n\nimagine this inline function:\n\n```python\n\u003e\u003e\u003e from fonc import fonc\n\u003e\u003e\u003e [\n...     fonc(\"\"\"\n... def x(input): # doesn't matter what this function is called\n...     value = input * 3.14\n...     return int(value)\n...     \"\"\")(value) for value in [1, 2, 3, 4]\n... ]\n[3, 6, 9, 12]\n```\n\nOne might imagine that this means that the `x` function name is overwritten to the global namespace. It is not!\n\n```py\n\u003e\u003e\u003e x(1)\n```\n\n```\nNameError: name 'x' is not defined\n```\n\n## how this works pls?\n\n-   parse the string and determine the name of the defined function\n-   replace that with a known random value\n-   replace calls to that inline function with calls to the renamed function\n\n## never-asked questions\n\n-   Do I have access to global vars inside this function?\n\n    ya\n\n-   Can I use this in production?\n\n    absolutely not u fool\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj6k4m8%2Ffonc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj6k4m8%2Ffonc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj6k4m8%2Ffonc/lists"}