On Mon, Jul 03, 2017 at 10:44:20PM +0100, Paul Moore wrote:

> > 1. Change BaseException. This allows people to pass the components
> >     to the message without ruining str(e).
> 
> I dispute this is the essential place to start. If nothing else, the
> proposed approach encourages people to use a position-based "args"
> attribute for exceptions, rather than properly named attributes.

Right -- and not only does that go against the exception PEP

https://www.python.org/dev/peps/pep-0352/

but it's still fragile unless the callee guarantees to always pass the 
values you want in the order you expect.

And even if they do make that promise, named attributes are simply 
better than positional arguments. Who wants to write:

    err.args[3]  # or is it 4, I always have to look it up...

when you could write:

    err.column

instead?



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to