7 Sep
2021
7 Sep
'21
3:34 p.m.
On 2021-09-07 11:12:37, Juancarlo Añez wrote:
Basically, the proposal is to allow for an exception type and value to be specified in *assert*, instead of the customary:
if not assertion:
raise ValueError('a message')
What's wrong with:
if __debug__: if not assertion: raise Exception
From what I can tell, this is optimised away when optimisations are turned on. Maybe wrap that in a function?
Perhaps the assertion would not go away with *-OO* when an exception type is specified?
Isn't the whole point of assertions that they go away with optimisations? If the code cannot be optimised away, raise the exception at runtime, it's just regular code.