{"id":15009901,"url":"https://github.com/koffiisen/smartswitchcase","last_synced_at":"2026-03-14T08:32:39.746Z","repository":{"id":57468600,"uuid":"308825957","full_name":"koffiisen/SmartSwitchCase","owner":"koffiisen","description":"Python library of implementation of Switch Case","archived":false,"fork":false,"pushed_at":"2020-11-01T09:21:55.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T17:17:20.834Z","etag":null,"topics":["libraries","library","python","python2","python3","switch","switchcase"],"latest_commit_sha":null,"homepage":"https://github.com/koffiisen/SmartSwitchCase","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/koffiisen.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":"2020-10-31T07:13:29.000Z","updated_at":"2021-10-18T15:51:10.000Z","dependencies_parsed_at":"2022-09-19T08:41:12.909Z","dependency_job_id":null,"html_url":"https://github.com/koffiisen/SmartSwitchCase","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/koffiisen%2FSmartSwitchCase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffiisen%2FSmartSwitchCase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffiisen%2FSmartSwitchCase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffiisen%2FSmartSwitchCase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koffiisen","download_url":"https://codeload.github.com/koffiisen/SmartSwitchCase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258505,"owners_count":20262300,"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":["libraries","library","python","python2","python3","switch","switchcase"],"created_at":"2024-09-24T19:29:04.603Z","updated_at":"2025-12-25T08:18:34.208Z","avatar_url":"https://github.com/koffiisen.png","language":"Python","funding_links":["https://www.paypal.me/smartjson"],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/smartswitchcase.svg)](https://pypi.org/project/smartswitchcase/)\n[![PyPI version](https://img.shields.io/pypi/pyversions/smartswitchcase.svg)](https://pypi.org/project/smartswitchcase/)\n[![PyPI version](https://img.shields.io/pypi/dm/smartswitchcase.svg)](https://pypi.org/project/smartswitchcase/)\n\n\n[![PyPI install](https://img.shields.io/badge/Link-Install-blue.svg)](https://pypi.org/project/smartswitchcase/)\n[![PyPI version](https://img.shields.io/badge/Link-GitHub-blue.svg)](https://github.com/koffiisen/smartswitchcase)\n[![PyPI download](https://img.shields.io/badge/Link-Download-blue.svg)](https://pypi.org/pypi/smartswitchcase#files)\n\n* ``BigQuery | Google cloud`` [\u003c==\u003e](https://cloud.google.com/bigquery/) \n\n[![Downloads](https://pepy.tech/badge/smartswitchcase)](https://pepy.tech/project/smartswitchcase)\n[![Downloads](https://pepy.tech/badge/smartswitchcase/month)](https://pepy.tech/project/smartswitchcase/month)\n[![Downloads](https://pepy.tech/badge/smartswitchcase/week)](https://pepy.tech/project/smartswitchcase/week)\n\n### Python library of implementation of Switch Case ([SmartSwitchCase](https://github.com/koffiisen/SmartSwitchCase))\n\n[SmartSwitchCase](https://github.com/koffiisen/SmartSwitchCase) is a simple library for use switch case statement.\n\n\n## Requirements\n\n[Python \u003e= 2.7](https://www.python.org/downloads/) must be installed.\n\n\n``Install``\n------------------------------------------------------------------------------\n\n``smartswitchcase`` is released on PyPI, so all you need is:\n\n    $ pip install smartswitchcase\n\nTo upgrade to latest version:\n\n    $ pip install --upgrade smartswitchcase\n\n\n# Usage\n\n### Basic Usage\n```python\nfrom smartswitchcase import SmartSwitchCase,Case\n\nvar = 2\n\n\ndef first():\n    print(\"I'm ... 1\")\n\n\ndef two():\n    print(\"I'm ... 2\")\n\n# Initialisation\nswc = SmartSwitchCase(var)\n# Add case\nswc.case(Case(1, first))\nswc.case(Case(2, two))\n# Add default statement\nswc.default(lambda: \"I'm ... Default\")\n# Run\nswc.exc()\n\n# \u003e\u003e\u003e CONSOLE : I'm ... 2 \u003c\u003c\u003c\n\n```\n\n### Advance Usage\n```python\nfrom smartswitchcase import SmartSwitchCase, Case\nimport random\n\nobj = random.randint(1, 11)\n\n\ndef first():\n    return \"I'm ... 1\"\n\n\ndef two():\n    return \"I'm ... 2\"\n\n\n# Initialisation\nswc = SmartSwitchCase(obj)\n# Add case\nswc.case(Case(1, first))\nswc.case(Case(2, two))\nswc.case(Case(3, lambda: \"I'm ... 3\"))\nswc.case(Case(4, lambda: \"I'm ... 4\"))\nswc.case(Case(5, lambda: \"I'm ... 5\"))\nswc.case(Case(6, lambda: \"I'm ... 6\"))\nswc.case(Case(7, lambda: obj * 7))\nswc.case(Case(8, lambda: 888))\nswc.case(Case(9, lambda: 999))\n# Add default statement\nswc.default(lambda: \"I'm ... Default\")\n# Run\nswc.exc()\n# If your statement return a result you can get her after execution\nresult = swc.result()\n# Show the result\nprint(result)\n```\n\n### Advance Usage Example (LIST)\n```python\nfrom smartswitchcase import SmartSwitchCase, Case\n\n# Initialisation\nswc = SmartSwitchCase([1, 2, 3, 4, 5])\n# Add case\nswc.case(Case([6, 7, 8], lambda: \"[6, 7, 8] Match with [1, 2, 3, 4, 5]\"))\nswc.case(Case([9, 10, 11], lambda: \"[6, 7, 8] Match with [1, 2, 3, 4, 5]\"))\nswc.case(Case([1, 2, 3, 4, 5], lambda: \"[1, 2, 3, 4, 5] Match with [1, 2, 3, 4, 5]\"))\nswc.case(Case([78, 17, 98], lambda: \"[78, 17, 98] Match with [1, 2, 3, 4, 5]\"))\n# Add default statement\nswc.default(lambda: \"I'm ... Default [1, 2, 3, 4, 5]\")\n# Run\nswc.exc()\n# If your statement return a result you can get her after execution\nresult = swc.result()\n# Show the result\nprint(result)\n```\n\n### Advance Usage Example (DICT)\n```python\nfrom smartswitchcase import SmartSwitchCase, Case\n\nmydict = {\n    \"data\": {\n        \"1\": {\"name\": \"Joel\"},\n        \"2\": {\"name\": \"Github \u0026 Python\"}\n    }\n}\n\n# Initialisation\nswc = SmartSwitchCase(mydict)\n# Add case\nswc.case(Case({\"data\": {\"1\": {\"name\": \"Hi\"}}}, lambda: \"Maybe 1\"))\nswc.case(Case({\"data\": {\"1\": {\"name\": \"Git\"}, \"2\": {\"name\": \"Github \u0026 Python\"}, }}, lambda: \"Maybe 2\"))\nswc.case(Case({\"data\": {\"1\": {\"name\": \"Joel\"}, \"2\": {\"name\": \"Github \u0026 Python\"}, }}, lambda: \"Maybe 3\"))\nswc.case(Case({\"data\": {\"1\": {\"name\": \"PyPi\"}, \"2\": {\"name\": \"Github \u0026 Python\"}, }}, lambda: \"Maybe 4\"))\nswc.case(Case({\"data\": {\"1\": {\"name\": \"Dict\"}, \"2\": {\"name\": \"Github \u0026 Python\"}, }}, lambda: \"Maybe 5\"))\n# Run\nswc.exc()\n# If your statement return a result you can get her after execution\nresult = swc.result()\n# Show the result\nprint(result)\n\n```\n\nDocumentation\n===============================================================================\n\n#### \n* [SmartSwitchCase](smartswitchcase/smartswitchcase.py) : Take one parameter (The statement value you want tested)\n* [Case](smartswitchcase/smartswitchcase.py) Take two parameters (value, func):\n    - value of case\n    - func is the execution function if case is match\n\n## Project structure:\n\n* `smartqwitchcase` - source code of a package\n* `examples` - working examples\n\n## Contribute\n\n1. If unsure, open an issue for a discussion\n1. Create a fork\n1. Make your change\n1. Make a pull request\n1. Happy contribution!\n\n\n### For support or coffee :)\n\n[![screenshot](https://github.com/koffiisen/SmartJson/blob/master/bymecoffee.PNG?raw=true) ](https://www.paypal.me/smartjson)\n\n## Author : [Koffi Joel ONIPOH](https://github.com/koffiisen)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoffiisen%2Fsmartswitchcase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoffiisen%2Fsmartswitchcase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoffiisen%2Fsmartswitchcase/lists"}