Why would one use assert False, 'error' vs raise AssertionError('error')?
Asked
Active
Viewed 294 times
0
Joshua Fox
- 18,704
- 23
- 87
- 147
s5s
- 11,159
- 21
- 74
- 121
-
1In this specific case, it should instead raise a `NotImplementedError` – L3viathan Jun 27 '20 at 19:40
-
Note that neither of these are adequate uses. ``NotImplementedError`` should be raised instead. – MisterMiyagi Jun 27 '20 at 19:40
1 Answers
0
Just this:
- You can then disable the assertion, by running your Python scripts with the
-Oswitch. - Using
assertgives consistency with other uses ofassert, in the more common cases where the assertion is non-constant rather than just0. (ButFalseshould really be used instead.)
Joshua Fox
- 18,704
- 23
- 87
- 147