{"id":19614681,"url":"https://github.com/activestate/recipe-580787-function-based-callbacks","last_synced_at":"2025-08-21T06:34:13.866Z","repository":{"id":66048051,"uuid":"224299462","full_name":"ActiveState/recipe-580787-function-based-callbacks","owner":"ActiveState","description":"Implementing function based callbacks in Python","archived":false,"fork":false,"pushed_at":"2019-11-27T18:08:34.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-09T10:30:45.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://platform.activestate.com/ActiveState-Recipes/recipe-580787-function-based-callbacks","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/ActiveState.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-26T22:44:08.000Z","updated_at":"2019-11-27T18:08:36.000Z","dependencies_parsed_at":"2023-03-27T17:56:44.220Z","dependency_job_id":null,"html_url":"https://github.com/ActiveState/recipe-580787-function-based-callbacks","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/ActiveState%2Frecipe-580787-function-based-callbacks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Frecipe-580787-function-based-callbacks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Frecipe-580787-function-based-callbacks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveState%2Frecipe-580787-function-based-callbacks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ActiveState","download_url":"https://codeload.github.com/ActiveState/recipe-580787-function-based-callbacks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240906818,"owners_count":19876682,"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":[],"created_at":"2024-11-11T10:53:20.273Z","updated_at":"2025-02-26T17:43:32.322Z","avatar_url":"https://github.com/ActiveState.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repository covers the following recipe from code.activestate.com:\n\n[IMPLEMENTING FUNCTION-BASED CALLBACKS IN PYTHON\n](https://code.activestate.com/recipes/580787-implementing-function-based-callbacks-in-python/)\n\n*Created by Vasudev Ram on Wed, 19 Apr 2017*\n\nThis recipe shows a simple way of implementing callbacks in Python. There are a few ways this can be done. The way shown here uses a simple function-based approach.\n\nIn a nutshell, a callback can be informally described like this: function a calls function b, and wants to make b run a specific independent chunk of code at some point during b's execution. We want to be able to vary which chunk of code gets called in different calls to b, so it cannot be hard-coded inside b. So function a passes another function, c, to b, as one argument, and b uses that parameter c to call the functionality that a wants b to call. (Function b may pass some parameters to the function represented by c, when it calls it. These could be either internally generated, passed from a, or a combination of both). So, by changing the value of the function c that gets passed to b (on different calls to b), a can change what chunk of code b calls.\n\nMore details and full code, description and output here:\n\n\u003chttps://jugad2.blogspot.in/2017/04/implementing-and-using-callbacks-in.html\u003e\n\n## Usage\n\nIf you already have the [State Tool] installed you can simply run\n\n```\nstate activate ActiveState-Recipes/recipe-/580787-implementing-function-based-callbacks-in-python\n```\n\nIf you do not have the [State Tool] installed you can use the following convenient one-liner.\n\nLinux: \n```\nsh \u003c(curl -q https://platform.activestate.com/dl/cli/install.sh) -n -f \u0026\u0026 state activate --path $HOME/ActiveState-Recipes/recipe-/580787-implementing-function-based-callbacks-in-python ActiveState-Recipes/recipe-/580787-implementing-function-based-callbacks-in-python\n```\n\nWindows: \n```\npowershell \"Set-Item -Path Env:NOPROMPT_INSTALL -Value 'true'; IEX(New-Object Net.WebClient).downloadString('https://platform.activestate.com/dl/cli/install.ps1')\" \u0026\u0026 state activate --path %APPDATA%/ActiveState-Recipes/recipe-/580787-implementing-function-based-callbacks-in-python ActiveState-Recipes/recipe-/580787-implementing-function-based-callbacks-in-python\n```\n\nmacOS: not yet supported\n\n[State Tool]: https://www.activestate.com/products/platform/state-tool/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivestate%2Frecipe-580787-function-based-callbacks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factivestate%2Frecipe-580787-function-based-callbacks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivestate%2Frecipe-580787-function-based-callbacks/lists"}