You can use assertions with the assert statement and that is the preferred way. The pattern here says you should not use assertions for some condition validation in your application logic — only use assertions in tests.
Somewhat, yes. However testing a condition and throwing an exception if it’s not met is exactly the kind of tedious task assertions were made to simplify, make easier to write and easier to read. So if you can’t use them in actual production code, it kinda defeats the purpose. Especially in a dynamically typed language where you have to type-check all your arguments.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can use assertions with the
assert
statement and that is the preferred way. The pattern here says you should not use assertions for some condition validation in your application logic — only use assertions in tests.I hope that clarifies the point! :)
Somewhat, yes. However testing a condition and throwing an exception if it’s not met is exactly the kind of tedious task assertions were made to simplify, make easier to write and easier to read. So if you can’t use them in actual production code, it kinda defeats the purpose. Especially in a dynamically typed language where you have to type-check all your arguments.