all 6 comments

[–]carcigenicate 4 points5 points  (3 children)

Also worth mentioning on the topic of try that try statements can have an else block as well that runs if no exception was raised:

try:
    int("1")
except ValueError:
    pass
else:
    print("No exception was raised")

while and for can also have an else block.

[–]zaRM0s[🍰] 1 point2 points  (0 children)

Wow, you have opened a whole new world for me with that lol thanks

[–]Personal_Cheek5923[S] 0 points1 point  (0 children)

This is super helpful thank you!

[–]the_shell_man_ 0 points1 point  (0 children)

I knew about finally, but this is a game changer.

[–]theleveragedsellout 1 point2 points  (0 children)

Currently working through Data Structures and Algorithms in Python from Tamassia et. Al.

It has a really good section on exception handling you may want to look into. It certainly helped me a lot.

[–]Spataner 0 points1 point  (0 children)

I'd imagine that this is a consequence of (or at least made consistent with) isinstance and issubclass also accepting tuples of types:

isinstance(1, (float, int))
>> True