Michael Robellard <m...@robellard.com> added the comment:
I can confirm that Juan Arrivillaga (juanpa.arrivillaga) workaround does work. Given that it works, then wouldn't it be relatively trivial to do what Thomas701 suggests and add a descriptor parameter to fields. Then apply the descriptor after all the other work is done so that it doesn't get clobbered, which is basically reproducing the workaround. import dataclasses @dataclasses.dataclass class FileObject: _uploaded_by: str = dataclasses.field(default=None, init=False) def _uploaded_by_getter(self): return self._uploaded_by def _uploaded_by_setter(self, uploaded_by): print('Setter Called with Value ', uploaded_by) self._uploaded_by = uploaded_by uploaded_by: str = field(default=None, descriptor=property( FileObject._uploaded_by_getter, FileObject._uploaded_by_setter)) p = FileObject() print(p) print(p.uploaded_by) This would allow any descriptor to be applied to a dataclass field. If we allow descriptor to accept an iterable as well you could have multiple descriptors just like normal. ---------- versions: +Python 3.10, Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39247> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com