[Python-ideas] Repurpose `assert' into a general-purpose check

Steven D'Aprano steve at pearwood.info
Thu Jan 18 01:59:03 EST 2018

On Thu, Jan 18, 2018 at 05:22:06PM +1100, Chris Angelico wrote:

> I haven't yet seen any justification for syntax here. The nearest I've
> seen is that this "ensure" action is more like:
> try:
>     cond = x >= 0
> except BaseException:
>     raise AssertionError("x must be positive")
> else:
>     if not cond:
>         raise AssertionError("x must be positive")
> Which, IMO, is a bad idea, and I'm not sure anyone was actually
> advocating it anyway.

My understanding is that Sylvain was advocating for that.


More information about the Python-ideas mailing list