Skip to main content

yesno

Given a string mapping values for true, false, and (optionally) None, return one of those strings according to the value:

==========  ======================  ==================================
Value Argument Outputs
========== ====================== ==================================
``True`` ``"yeah,no,maybe"`` ``yeah``
``False`` ``"yeah,no,maybe"`` ``no``
``None`` ``"yeah,no,maybe"`` ``maybe``
``None`` ``"yeah,no"`` ``"no"`` (converts None to False
if no mapping for None is given.
========== ====================== ==================================
def yesno(
value: any,
arg: string = None
) - > string

Given a string mapping values for true, false, and (optionally) None, return one of those strings according to the value.

Parameters

NameTypeDescription
valueanyThe input value to be evaluated for truthiness or nullity.
argstring = NoneA comma-separated string defining the mappings for true, false, and optionally None (e.g., "yes,no,maybe").

Returns

TypeDescription
stringThe mapped string corresponding to the truthiness of the input value, or the original value if the argument format is invalid.