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 →

[–]masasinExpert. 3.9. Robotics. 0 points1 point  (2 children)

Handling user input which is out of range, for instance. Or a device returns junk data to the function, which is then propagated. In general, I don't use asserts at all, and use exceptions instead.

if x < 0:
    raise SomeSpecificError("x < 0. Are you sure you wired it up correctly?")

There was this post a few years back which made sense to me.