+ 1
Can someone properly explain "assert"?
I recently learned the module about the "assert" command in Python and I still can't figure out the difference between that and other errors. What's the difference? Does it cause an assertion error even if it occurs a lot later in the program? I'm not sure I understood anything at all...
2 odpowiedzi
+ 2
Ensures the condition is true or raises an AssertionError. Useful during debugging/testing and often replaced with an if statement for release code.
https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/assertions_in_python.htm
https://docs.python.org/2.0/ref/assert.html
+ 1
Thank you! I did wonder why not simply use if.
Guess it all lies in the original purpose