<p dir="ltr">I feel like you just brought up the exact issue. Assertions should *never* be used for things like this. Because, one day, some stupid idiot is going to use assertions to perform some sort of data validation, someone else will use that library with -O, and the world will explode.</p>
<p dir="ltr">It's just far too attractive to use but far too easy to misuse. And, if you really want:</p>
<p dir="ltr">if my_cond: raise MyError('abc')</p>
<p dir="ltr">Compare that to:</p>
<p dir="ltr">assert my_cond, MyError('abc')</p>
<p dir="ltr">Also, RPython uses assertions for error handling. Trust me, dealing with that is *not* fun.</p>
<p dir="ltr">--<br>
Ryan<br>
[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.<br>
<a href="http://kirbyfan64.github.io/">http://kirbyfan64.github.io/</a></p>
<div class="gmail_quote">On May 2, 2016 10:29 AM, "Giampaolo Rodola'" <<a href="mailto:g.rodola@gmail.com">g.rodola@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 2, 2016 at 5:17 PM, Random832 <span dir="ltr"><<a href="mailto:random832@fastmail.com" target="_blank">random832@fastmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Mon, May 2, 2016, at 11:14, Guido van Rossum wrote:<br>
> On Mon, May 2, 2016 at 8:01 AM, Ryan Gonzalez <<a href="mailto:rymg19@gmail.com" target="_blank">rymg19@gmail.com</a>> wrote:<br>
><br>
> > Other than the fact that this would completely fail when run with -O...<br>
> ><br>
> But maybe that's fine, or intended.<br>
><br>
> I can see a fair number of uses for this, including subclasses of<br>
> AssertionError.<br>
<br>
</span>I think this would be an attractive nuisance, and if it's implemented at<br>
all it should forbid types that are *not* subclasses of AssertionError<br>
in order to mitigate that.</blockquote><div><br></div><div>Why such a constraint? I think most of the times the desired exception would be either ValueError or TypeError, both of which do not inherit from AssertionError.</div><div><br></div></div>-- <br><div><div dir="ltr"><div>Giampaolo - <a href="http://grodola.blogspot.com" target="_blank">http://grodola.blogspot.com</a></div><div><br></div></div></div>
</div></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div>