On 5/2/2020 12:20 PM, Soni L. wrote:


On 2020-05-02 1:07 p.m., Steven D'Aprano wrote:
On Sat, May 02, 2020 at 12:50:19PM -0300, Soni L. wrote:

> how about:
> > result = Foo.save()
> try:
>   x, y = result
> except ValueUnpackingError:
>   return ...

If you do that, what benefit is ValueUnpackingError over just
ValueError?



unpacking (a generator) still doesn't wrap ValueError, and ValueError is raised a lot more than ValueUnpackingError.

Has anyone actually had that problem? And if they did, make it:

result = tuple(Foo.save())
try:
    x, y = result
except ValueError:
    ...

You could even check the length of result before assigning it if you wanted to do something fancier without exceptions at all. But it seems silly to me.

Since I've seen no actual examples of code that would benefit, I'm still -1 on this particular exception, and -1 on a general-purpose addition of exceptions.

Eric
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ACF4SGCUT2F2EQPLW4USIP2KWQO5YB2E/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to