On Wed, Oct 14, 2020 at 1:41 AM Ronald Oussoren via Python-ideas <python-ideas@python.org> wrote: > > #— (python 3.9) > > import dataclasses > > @dataclasses.dataclass > class MyException (Exception): > a : int > b : str > > > try: > raise MyException(a=1, b="hello") > > except MyException as exc: > print(f"{exc.a=}, {exc.b=}”) > > # — >
I like it. Very elegant. Never thought of a dataclass as an exception. 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/D4T4M5A6DANTU5ZGARVAWSMKSVA5MWEW/ Code of Conduct: http://python.org/psf/codeofconduct/