I love assert

Grant Edwards invalid at invalid.invalid
Tue Nov 11 16:43:45 EST 2014


On 2014-11-11, Ben Finney <ben+python at benfinney.id.au> wrote:

> An ‘assert’ statement in the code will sometimes be active, and
> sometimes be a no-op, for *exactly* the same code under different
> circumstances.

Yep, it's the same in C, C++, Java, PHP, and other languages.  I think
most people know that asserts can be disabled (either at run-time or
compile time), and often are for performance reasons.

> That's a trap for the reader, and I'd rather not set it.

Personally, I find that too many asserts often makes code hard to read
just because of the visual clutter and the veritical "spread" it
induces.

-- 
Grant Edwards               grant.b.edwards        Yow! I hope I bought the
                                  at               right relish ... zzzzzzzzz
                              gmail.com            ...



More information about the Python-list mailing list