Wednesday, June 27, 2018

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

> but still I can NOT think out one useful situation.

Sorry for the typo.

在 2018年6月27日星期三 UTC+8下午10:10:29,laixintao写道:
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?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d96fa435-1324-4d8d-bdb8-7e54b1f9dfa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment