>
> I sometimes wish that Python included a richer set of assertions rather
> than just a single `assert` keyword. Something like Eiffel's concept of
> pre-conditions, post-conditions and invariants, where each can be
> enabled or disabled independently.


Has something like this been proposed for Python before?
This seems to align more with the intended use of assert that's been
pointed out in this thread.
In what case though would one want to disable some but not all of these
pre, post, or invariant assertions?

On Thu, Jan 18, 2018 at 2:12 AM, Ethan Furman <[email protected]> wrote:

> On 01/17/2018 10:59 PM, Steven D'Aprano wrote:
>
>> 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.
>>
>
> Agreed.  Which, as has been pointed out, is an incredibly bad idea.
>
> --
> ~Ethan~
>
>
> _______________________________________________
> Python-ideas mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>

ᐧ
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to