I love assert
Ethan Furman
ethan at stoneleaf.us
Wed Nov 12 17:56:46 EST 2014
On 11/12/2014 02:47 PM, Marko Rauhamaa wrote:
> Ian Kelly <ian.g.kelly at gmail.com>:
>
>> Although to be honest I'd rather use something like "raise
>> RuntimeError('Unreachable code reached')" than "assert False" here. If
>> the expectation is that the code will never be executed, then there's
>> no reason to ever optimize it out.
>
> Asserts have nothing to do with them being optimized out. Asserts are
> communication.
Asserts are code that can stop your program. That's a bit more than just communication. And your example of how you
use asserts shows a bad way to use them, which has been explained. Apparently you refuse to learn from that, but
hopefully somebody else will.
--
~Ethan~
More information about the Python-list
mailing list