I love assert

Marko Rauhamaa marko at pacujo.net
Thu Nov 13 00:01:07 CET 2014

Anton <anschatten at gmail.com>:

> Right, but the goal is not to make the CONFUSED status be handled
> without coding, but to be notified about an unknown status code and
> act accordingly.

Asserts are not about notification, checking or optimization. They are
about communicating what's going on in the programmer's mind. They are

So why use asserts instead of comments?

Asserts *could* help in fixing bugs:

  1. An assertion failure immediately, unambiguously, declares even to
     customer service representatives that this is a terrible bug and
     should be brought to R&D's attention instead of hazing the poor
     customer with standard questions ("have you updated?", "have you

  2. An assertion failure probably gives the developer an very good clue
     as to what has gone wrong. There is a good chance of quickly
     finding an accurate analysis and fix to the bug.


More information about the Python-list mailing list