Kaydet (Commit) 2a637a45 authored tarafından Sergey Fedoseev's avatar Sergey Fedoseev Kaydeden (comit) Tim Graham

[2.1.x] Refs #29478 -- Doc'd how to use cached_property with a mangled name.

Backport of 09199734 from master
üst 0211393b
...@@ -505,6 +505,15 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004 ...@@ -505,6 +505,15 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
z = person.friends # does not call z = person.friends # does not call
x is z # is True x is z # is True
.. warning::
``cached_property`` doesn't work properly with a mangled__ name unless
it's passed a ``name`` of the form ``_Class__attribute``::
__friends = cached_property(get_friends, name='_Person__friends')
__ https://docs.python.org/3/faq/programming.html#i-try-to-use-spam-and-i-get-an-error-about-someclassname-spam
.. function:: keep_lazy(func, *resultclasses) .. function:: keep_lazy(func, *resultclasses)
Django offers many utility functions (particularly in ``django.utils``) Django offers many utility functions (particularly in ``django.utils``)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment