qgis_deployment_toolbelt.utils.str2bool module

Basic string to bool.

qgis_deployment_toolbelt.utils.str2bool.str2bool(input_var: bool | str, raise_exc: bool = False) bool | None

Determine if a string is a bool and, if so, convert it.

  • input_var (str) – value to convert

  • raise_exc (bool, optional) – strict mode, defaults to False. Defaults to False.

  • ValueError – input_var is not in true and false sets

  • TypeError – if input_var is not a str or a bool


True if input_var is in _true_set, False if it’s in _false_set.

Return type:


None or Exception if not in any of two sets.