On Wed, Oct 14, 2020 at 4:48 AM David Mertz <[email protected]> wrote:
> Well, technically you could memoize calls to ExceptionMaker and have this
> work.
>
> In [11]: try:
> ...: raise ExceptionMaker("BadStuffError")
> ...: except ExceptionMaker("BadStuffError"):
> ...: print("caught")
> ...:
> caught
>
> I am NOT recommending this pattern. But it works in current Python.
>
ExceptionMaker = defaultdict(lambda name: type(name, (Exception,), {}))
And use square brackets.
ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/TOWC5B7XCIEZAAUTAUDA5QJLH5IIYBLF/
Code of Conduct: http://python.org/psf/codeofconduct/