News for hackers. Stuff that matters.
Re:The best Python feature you cannot use by boothby on Saturday June 17, 2023 @04:00PM (#36373987)
As a bit of a joke I wrote a library for this once

https://github.com/boothby/dissert

The big problem is that some people use assert wrong. There's a distinct time and place for asserts, and that's for testing purely internal logic. If you're testing anything that can be tainted with user data, that must be done with a conditional & exception.

Dissert saves the day! You can disable asserts on a per-file basis, and get that PYTHONOPTIMIZE experience with no perceived loss of safety. Of course, it uses the horrid content-encoding hack to trim assertions out of your code, so I make no guarantees.

There are no comments on this comment yet.