I love assert

Tim Chase python.list at tim.thechases.com
Tue Nov 11 18:03:26 EST 2014


On 2014-11-11 11:40, Peter Cacioppi wrote:
> I get the impression that most Pythonistas aren't as habituated
> with assert statements as I am. Is that just a misimpression on my
> part?

I tend to use it to catch my bone-headedness rather than actual
tests.  I'm particularly fond of one that catches me typing
"obj.exceptions" rather than "obj.exemptions" (both are common and
occasionally interchangeable terms in $DAYJOB) something along the
lines of

  assert hasattr(obj, "exceptions"), "idiot programmer"

-tkc






More information about the Python-list mailing list