On Mon, 18 Jan 2021 12:41:45 -0800 Chris Barker via Python-Dev <python-dev@python.org> wrote: > > And in "real world" code, I've done just this -- building a system for > saving / restoring dataclasses to/from JSON. In that case, each of the > dataclasses knows how to save itself and build itself from JSON-compatible > python objects (numbers, dicts, strings, lists) -- so again, no need for > pattern matching there either. And what I really like about the approach of > putting all the logic in the "nodes" is that I can make new types of nodes > without having to touch the code at the "top" that visits those nodes.
Note that another approach is the little-used `functools.singledispatch`. Regards Antoine. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/PD5PIBOLSHL3I7TC7XDCEDKRPRHAJPEY/ Code of Conduct: http://python.org/psf/codeofconduct/