[Python-ideas] Arguments to exceptions
Mark E. Haase
mehaase at gmail.com
Thu Jul 6 16:29:25 EDT 2017
On Thu, Jul 6, 2017 at 2:56 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> > Maybe I'm misunderstanding you, but the proposal has a clear example of
> > raising NameError and getting the name attribute from the exception
> > instance:
> >
> > try:
> > raise NameError(name=name, template="name '{name}' is not
> defined.")
> > except NameError as e:
> > name = e.kwargs['name']
> > msg = str(e)
> > ...
>
> What prevents the programmer from writing this?
>
> raise NameError(nym=s, template="name '{nym}' is not defined.")
>
> Or any other keyword name for that matter. Since the exception class
> accepts arbitrary keyword arguments, we have to expect that it could be
> used with arbitrary keyword arguments.
>
I agree completely with your point here, as well as the overall conclusion
that the proposal to change BaseException is a bad idea. I was merely
replying to [what I perceived as] straw manning of the proposal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170706/0588ba04/attachment.html>
More information about the Python-ideas
mailing list