+ 3
so the assertion will terminate the program and the try-exxcept won't?
2 odpowiedzi
+ 5
1. Yes
2. Reasons
Assertion is
- for testing,
- for the development phase,
- for checking if interim data state are as expected.
Try-except / Try-catch is
- for releasal,
- for the production phase,
- for not harming user experience.
3. Examples
https://code.sololearn.com/cBc5B5dnk7BJ/?ref=app
https://code.sololearn.com/cK3pBr78iT2d/?ref=app
+ 1
Assertion throws AssertionError so if assertion failed program will exit