On Wed, Oct 14, 2020 at 4:48 AM David Mertz <me...@gnosis.cx> 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 -- 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/TOWC5B7XCIEZAAUTAUDA5QJLH5IIYBLF/ Code of Conduct: http://python.org/psf/codeofconduct/