You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some places assert statements are being used to perform some kind of validation, e.g.: type of an argument, value of an argument, etc.
These statements should be replaced with proper validation mechanisms that will raise an appropriate Exception and do whatever is necessary from the point of view of the protocol, because such assert statements may be removed if optimization is turned on. From the Python docs:
The current code generator emits no code for an assert statement when optimization is requested at compile time.
Assertions should not be used to test for failure cases that can occur because of bad user input or operating system/environment failures, such as a file not being found. Instead, you should raise an exception, or print an error message, or whatever is appropriate. One important reason why assertions should only be used for self-tests of the program is that assertions can be disabled at compile time.
In some places
assert
statements are being used to perform some kind of validation, e.g.: type of an argument, value of an argument, etc.These statements should be replaced with proper validation mechanisms that will raise an appropriate
Exception
and do whatever is necessary from the point of view of the protocol, because suchassert
statements may be removed if optimization is turned on. From the Python docs:Resources
https://wiki.python.org/moin/UsingAssertionsEffectively:
https://dbader.org/blog/python-assert-tutorial:
https://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python
The text was updated successfully, but these errors were encountered: