Assertions are bad, m'kay?

Chris Angelico rosuav at gmail.com
Fri Mar 7 06:24:29 EST 2014


On Fri, Mar 7, 2014 at 10:11 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
>> http://xkcd.com/1339/
>>
>> Abusing assert for arg checking violates XKCD 1339. Write
>> standards-compliant code!
>
> Assertions are not bad! They're just misunderstood and abused.
>
> (By the way, assertions are not the same as assumptions. Asserts can be
> used to check that assumptions are correct, or to check the internal
> logic of your reasoning. Whereas assumptions are just accepted as if they
> were correct, no questions asked.

The XKCD does draw a distinction between assuming and asserting. And I
do say "for arg checking", which is the most common *abuse* of assert.
But mainly, I just like to share laughs :)

ChrisA



More information about the Python-list mailing list