{"id":16505555,"url":"https://github.com/davidbrochart/nbbranch","last_synced_at":"2025-08-31T14:03:57.193Z","repository":{"id":88094105,"uuid":"291822262","full_name":"davidbrochart/nbbranch","owner":"davidbrochart","description":"Branching in the Jupyter Notebook","archived":false,"fork":false,"pushed_at":"2020-08-31T21:24:49.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-23T05:08:30.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/davidbrochart.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-31T20:52:55.000Z","updated_at":"2020-08-31T21:24:51.000Z","dependencies_parsed_at":"2023-05-18T07:00:48.071Z","dependency_job_id":null,"html_url":"https://github.com/davidbrochart/nbbranch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davidbrochart/nbbranch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidbrochart%2Fnbbranch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidbrochart%2Fnbbranch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidbrochart%2Fnbbranch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidbrochart%2Fnbbranch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidbrochart","download_url":"https://codeload.github.com/davidbrochart/nbbranch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidbrochart%2Fnbbranch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272988919,"owners_count":25026961,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-11T15:12:23.855Z","updated_at":"2025-08-31T14:03:57.168Z","avatar_url":"https://github.com/davidbrochart.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nbbranch: branching in the Jupyter Notebook\n\n## What if you could branch over multiple cells?\n\nYou would argue, just merge the cells and use the built-in Python `if`/`elif`/`else` statements. Except that a cell can have an output (some text, an image, a widget...), and so by branching over multiple cells you can generate several outputs conditionally. In the context of [Voila](https://github.com/voila-dashboards/voila), this means you can e.g. have a dynamically generated dashboard.\n\n## What does it look like?\n\n`nbbranch` is implemented as IPython magic commands.\n\n```python\n%load_ext nbbranch\n\na = 1\n\n#\n\n%%IF a == 0:\nprint('foo')\n\n# no output\n\n%%ELIF a == 1:\nprint('bar1')\n\n# prints \"bar1\"\n\n%%IF True:\nprint('True')\n\n# prints \"True\"\n\n%ENDIF\n\n#\n\n%%IF\nprint('bar2')\n\n# prints \"bar2\"\n\n%%ELIF a == 2:\nprint('baz')\n\n# no output\n\n%%ELSE\nprint('ERROR')\n\n# no output\n\n%ENDIF\n```\n\nA few remarks:\n- We use upper-case equivalents of built-in Python branching keywords (`IF`, `ELIF`, `ELSE`).\n- These keywords must be prefixed with `%` if the reminder of the cell is empty, or `%%` otherwise (general magic syntax).\n- Indentation is not required (this may change in the future).\n- We need an `%ENDIF` to mark the end of a corresponding `%IF`.\n- Between the outer-most `%IF`/`%ENDIF`, all cells must start with one of `%IF`, `%ELIF`, `%ELSE` or `%ENDIF`. If the cell is just the continuation of the cell above, its first line must be an empty `%%IF`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidbrochart%2Fnbbranch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidbrochart%2Fnbbranch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidbrochart%2Fnbbranch/lists"}