On Wed, Oct 14, 2020 at 1:41 AM Ronald Oussoren via Python-ideas <[email protected]> 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 -- [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/D4T4M5A6DANTU5ZGARVAWSMKSVA5MWEW/ Code of Conduct: http://python.org/psf/codeofconduct/
