Why do we need @cached_property behave like property when access from class?

35 views
Skip to first unread message

赖信桃

unread,
Jun 27, 2018, 10:10:29 AM6/27/18
to django...@googlegroups.com
Hi, I'm reading the django's source code, and I am quite confused by https://github.com/django/django/pull/812/files and https://code.djangoproject.com/ticket/19872#no2

Why @cached_property need to return self when access from class? https://docs.djangoproject.com/zh-hans/2.0/_modules/django/utils/functional/#cached_property

I see this PR for sure can make @cached_property behave like python's @property, I have tested by myself here: https://gist.github.com/laixintao/f1114d964c19679c973c2c3c3f1fa8ba#gistcomment-2631456 , but still I can think out one useful situation.

Can somebody provide a condition that @cached_problem will cause problems without return self when access from class?

laixintao

unread,
Jun 27, 2018, 10:14:07 AM6/27/18
to Django users
> but still I can NOT think out one useful situation.

Sorry for the typo.

在 2018年6月27日星期三 UTC+8下午10:10:29,laixintao写道:
Reply all
Reply to author
Forward
0 new messages