Advantages of Default Factory in Dataclasses

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Tue Nov 16 08:04:05 EST 2021


Greetings list,

A simple question: why do we need field(default_factory ) in dataclasses?

Why not make that field as an attribute return a function?

Useful implementation examples / use cases appreciated.

Kind Regards,

Abdur-Rahmaan Janhangeer
about <https://compileralchemy.github.io/> | blog
<https://www.pythonkitchen.com>
github <https://github.com/Abdur-RahmaanJ>
Mauritius


More information about the Python-list mailing list