Nov. 16, 2013
3:32 a.m.
Should stdlib code use assert at all?
If user input can trigger an assert, then the code should raise a normal exception that will not disappear with -OO.
If the assert is testing program logic, then it seems that the test belongs in the test file, in this case, test/test_datetime.py. For example, consider the following (backwards) code.
Is there any policy on use of assert in stdlib production code?
It is my assertion that assert should only be used where a system-level problem would occur, where you cannot trap an error condition. -- MarkJ Tacoma, Washington