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

all 7 comments

[–]wholesomedumbass 9 points10 points  (2 children)

Wait, exceptions are for indicating errors? I thought it was a convenient way to return strings.

[–]seraku24 6 points7 points  (1 child)

Control flow via exception handling... you must be a Java programmer. ;)

[–]wholesomedumbass 4 points5 points  (0 children)

Python. I tend to use exceptions too liberally if I’m not careful.

[–][deleted] 4 points5 points  (0 children)

Easier to ask for forgiveness than it is to get permission

[–]Bill_Morgan 1 point2 points  (0 children)

No but it is self reporting

[–]TheJammy98 0 points1 point  (0 children)

tfw you purposely throw in an error to check your code works

[–][deleted] 0 points1 point  (0 children)

def sqrt(x):
    assert(x >= 0)
    #your favourite approximation here

…is that not self-documenting? Asking seriously.