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.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CGLR45ZAKGLJ3AEB3GJCJZ5MNE7UWLWX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to