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

Serhiy Storchaka storchaka at gmail.com
Tue Nov 28 15:42:20 EST 2017

28.11.17 15:36, Nick Coghlan пише:
> * I'm opposed to making assert substantially different from the way it works now

If sometimes we will change assert I would prefer to make it more 
similar to assert in pytest. Output values of the final and intermediate 
expressions. The hardest problem -- the repr can be very long and 
expensive, we need an alternate protocol for producing a shortened 

> * I'm in favour of adding a new "ensure()" builtin that encapsulates
> the check-and-raise logic

Then may be add a new "die()" buildin? ;-)

     0 <= r < abs(y) or die()

More information about the Python-ideas mailing list