[Python-Dev] (#19562) Asserts in Python stdlib code (datetime.py)

Steven D'Aprano steve at pearwood.info
Sun Nov 17 08:42:25 CET 2013

On Sat, Nov 16, 2013 at 11:16:48AM -0500, Donald Stufft wrote:
> Personally I think that none of the -O* should be removing asserts. It feels
> like a foot gun to me. I’ve seen more than one codebase that would be
> completely broken under -O* because they used asserts without even knowing
> -O* existed.

I agree that many people misuse asserts. I agree that this is a problem 
for them. But I disagree that the solution is to remove what I consider 
to be a useful feature, and a common one in other languages, just to 
protect people from their broken code.

I prefer to see better efforts to educate them. To that end, I've taken 
the liberty of sending a post to python-list at python.org describing when 
to use asserts, and when not to use them:


I will continue to use my best effort to encourage good use of 
assertions in Python.


More information about the Python-Dev mailing list