cobald.utility package
- cobald.utility.enforce(condition: bool, exception: BaseException = InvariantError())[source]
Enforce that
condition
is set by raisingexception
otherwiseThis is a replacement for
assert
statements as part of validation. It cannot be disabled with-O
and may raise arbitrary exceptions.def sqrt(value): condition(value > 0, ValueError('value must be greater than zero') return math.sqrt(value)