[issue38524] functools.cached_property is not supported for setattr

Serhiy Storchaka report at bugs.python.org
Sat Oct 19 05:23:18 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

You have to call __set_name__() if you create a cached_property dynamically outside of the class namespace.

p = cached_property(age)
p.__set_name__(cls, 'age3')
cls.age3 = p

(And setattr() is not needed here.)

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38524>
_______________________________________


More information about the Python-bugs-list mailing list