Thank you for your explanation!
ᐧ

On Thu, Jan 18, 2018 at 11:00 PM, Guido van Rossum <gu...@python.org> wrote:

> On Thu, Jan 18, 2018 at 7:51 PM, Nikolas Vanderhoof <
> nikolasrvanderh...@gmail.com> wrote:
>
>> 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?
>>
>
> Oh, many times, starting in the late '90s IIRC (Paul Dubois was a big fan).
>
> The problems are twofold: (a) it would require a lot of new keywords or
> ugly syntax; and (b) there would have to be a way to enable each form
> separately *per module or package*. Eiffel solves that (AFAIC) through
> separate compilation -- e.g. a stable version of a library might disable
> invariants and post-conditions but keep pre-conditions, since those could
> be violated by less mature application code; or a mature application could
> disable all checks and link with optimized library binaries that also have
> disabled all checks. I'm sure other scenarios are also viable.
>
> But that solution isn't available in Python, where command line flags
> apply to *all* modules being imported.
>
> (Note: even if you have a solution for (b), getting past (a) isn't so
> easy. So don't get nerd-sniped by the solution for (b) alone.)
>
> --
> --Guido van Rossum (python.org/~guido)
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to