BigQuery | Google cloud<==>
Python library of implementation of Switch Case (SmartSwitchCase)
SmartSwitchCase is a simple library for use switch case statement.
Requirements
Python >= 2.7 must be installed.
Install
smartswitchcase is released on PyPI, so all you need is:
$ pip install smartswitchcase
To upgrade to latest version:
$ pip install --upgrade smartswitchcase
Usage
Basic Usage
from smartswitchcase import SmartSwitchCase,Case
var = 2
def first():
print("I'm ... 1")
def two():
print("I'm ... 2")
# Initialisation
swc = SmartSwitchCase(var)
# Add case
swc.case(Case(1, first))
swc.case(Case(2, two))
# Add default statement
swc.default(lambda: "I'm ... Default")
# Run
swc.exc()
# >>> CONSOLE : I'm ... 2 <<<
Advance Usage
from smartswitchcase import SmartSwitchCase, Case
import random
obj = random.randint(1, 11)
def first():
return "I'm ... 1"
def two():
return "I'm ... 2"
# Initialisation
swc = SmartSwitchCase(obj)
# Add case
swc.case(Case(1, first))
swc.case(Case(2, two))
swc.case(Case(3, lambda: "I'm ... 3"))
swc.case(Case(4, lambda: "I'm ... 4"))
swc.case(Case(5, lambda: "I'm ... 5"))
swc.case(Case(6, lambda: "I'm ... 6"))
swc.case(Case(7, lambda: obj * 7))
swc.case(Case(8, lambda: 888))
swc.case(Case(9, lambda: 999))
# Add default statement
swc.default(lambda: "I'm ... Default")
# Run
swc.exc()
# If you statement return a result you can get her after execution
result = swc.result()
# Show the result
print(result)
Documentation
- SmartSwitchCase : Take one parameter (The statement value you want tested)
- Case Take two parameters (value, func):
- value of case
- func is the execution function if case is match
Project structure:
smartqwitchcase- source code of a packageexamples- working examples
Contribute
- If unsure, open an issue for a discussion
- Create a fork
- Make your change
- Make a pull request
- Happy contribution!
For support or coffee :)
Author : Koffi Joel ONIPOH
Metadata
Release files for smartswitchcase 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smartswitchcase-1.0.tar.gz | 3.3 kB | Without provenance | Details for smartswitchcase-1.0.tar.gz |
Release files / smartswitchcase-1.0.tar.gz
| Download URL | smartswitchcase-1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7188b7a3fb861ef1813f2b88fd843f75a0bce0182749c3e24cc5895b63d9feca
|
|
BLAKE2b-256 checksum How to use checksums |
4cba1f24245360890edd25bb45e9a3dbf2e91815e4cc72e0520f04c072d53fee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.0
|
Security for smartswitchcase 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.