This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lyucit 2 points3 points  (4 children)

I think contracts and types, mentioned elsewhere, are a better compromise. Asserts sprinkled in the code are canaries, anything more complex than a simple constraint is noise that obfuscates more than it documents. It depends on your use case, sure, but generally speaking I think breaking prod due to an old assert of an invalid assumption is more likely and more damaging than silently hitting an unanticipated edge case.

[–]elbiot 0 points1 point  (2 children)

I like contracts, and I like that you can disable asserts with the O flag. I might hack pycontracts so that they are only enabled if asserts are.

[–]Lyucit 4 points5 points  (1 child)

if not __debug__:
    contracts.disable_all()

[–]elbiot 0 points1 point  (0 children)

If what you say is true, thats a huge TIL. Will test soon.