cmatrix.switch

cmatrix.switch()

Redefined C-like switch. Could also be used as an inverse switch where x is a value and arg the differents variables to test.

Parameters

Type

Description

x

string

the variable name to switch

arg

string/generic

the differents states to switch, defined mod 2 :

“string”,function,”string”,function,…

Returns
Generic

The function or action corresponding to the switch entry.

Examples

>>> test1=False
>>> test2=False
>>> test3=True
>>> test4=False
>>> val=switch(True,
...     test1,1,
...     test2,2,
...     test3,3,
...     test4,4)
>>> print(val)
3
>>> val=switch(test3,
...     True,3,
...     False,4)
>>> print(val)
3