Docstrings

exceptbool.except_converter(*, exc=<class 'Exception'>, to=False)[source]

Makes managed context to yield ConvertedExcept instance (a wrapped bool object) instead of raising an exception by converting given exception(s) into given bool value.

If no exception will be raised, then negation of given bool will be wrapped and yield. If exception different than given one will be raised, then it will not be caught.

Parameters:
  • exc (BaseException or tuple(BaseException)) – exception(s) to catch and convert; defaults to Exception
  • to – value to which caught exception will be converted and yield; defaults to False
Type:

bool

exceptbool.except_to_bool(_func=None, *, exc=<class 'Exception'>, to=False)[source]

Makes decorated function return bool instead of raising an exception by converting given exception(s) into given bool value.

If no exception will be raised, then negation of given bool will be returned. If exception different than given one will be raised, then it will not be caught.

Parameters:
  • _func – filled automatically by decorator with decorated function - DO NOT fill this param manually
  • exc (BaseException or tuple(BaseException)) – exception(s) to catch and convert; defaults to Exception
  • to – value to which caught exception will be converted and returned; defaults to False
Type:

bool

class exceptbool.converted_except.ConvertedExcept(value)[source]

Bases: object

Wraps bool object into mutable, non-singleton class.

value

Gets wrapped bool object. :return: wrapped bool object :rtype: bool