<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 7, 2013 at 2:20 PM, Eric Snow <span dir="ltr"><<a href="mailto:ericsnowcurrently@gmail.com" target="_blank">ericsnowcurrently@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, Nov 7, 2013 at 11:44 AM, Brett Cannon <<a href="mailto:brett@python.org">brett@python.org</a>> wrote:<br>


> Lazy message creation through<br>
> __str__ does leave the message out of `args`, though.<br>
<br>
</div>If that's an issue you could make args a (settable) property that<br>
dynmically returns str(self) if appropriate:<br>
<br>
    @property<br>
    def args(self):<br>
        actual = super().args<br>
        if actual or <a href="http://self.name" target="_blank">self.name</a> is None:<br>
            return actual<br>
        return (str(self),)<br></blockquote><div><br></div><div>Good point. That would solve that backwards-compatibility issue and allow the raising of DeprecationWarning.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div class="im"><br>
><br>
> In a perfect world (Python 4 maybe?) BaseException would take a single<br>
> argument which would be an optional message, `args` wouldn't exist, and<br>
> people called `str(exc)` to get the message for the exception. That would<br>
> allow subclasses to expand the API with keyword-only arguments to carry<br>
> extra info and have reasonable default messages that were built on-demand<br>
> when __str__ was called. It would also keep `args` from just being a dumping<br>
> ground of stuff that has no structure except by calling convention (which is<br>
> not how to do an API; explicit > implicit and all). IOW the original dream<br>
> of PEP 352 (<a href="http://python.org/dev/peps/pep-0352/#retracted-ideas" target="_blank">http://python.org/dev/peps/pep-0352/#retracted-ideas</a>).<br>
<br>
</div>This reminds me that I need to revisit that idea of reimplementing all<br>
the builtin exceptions in pure Python. :)<br></blockquote><div><br></div><div>Ah, that idea. =) Definitely a question of performance. </div></div></div></div>