Maybe you could start by writing this as a separate decorator, to be applied on top of the data class decorator?
On Wed, Dec 9, 2020 at 05:38 sam bland <[email protected]> wrote: > In response to the additional work required to convert the new python > dataclass using the json encoder I propose an __encode__ method that will > be included in the default dataclass attributes. This would then be picked > up by the default json encoder and called to encode the object. Using a > common __encode__ tag would allow the solution to also be applied to custom > objects and other new objects without needing to update all json encoders. > The __encode__ method would work similar to __repr__ but output a json > string of the object. > _______________________________________________ > 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/YGUCQH2XGERESIIWZ4TBU74HJKZATDWB/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido (mobile)
_______________________________________________ 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/CA2YGXBY6RS2FYVML7VYLUW5OSKMKRKE/ Code of Conduct: http://python.org/psf/codeofconduct/
