Просмотр исходного кода

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

Sergey Fedoseev 6 лет назад
Родитель
Сommit
09199734d3
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      docs/ref/utils.txt

+ 9 - 0
docs/ref/utils.txt

@@ -501,6 +501,15 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
         z = person.friends         # does not call
         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)
 
     Django offers many utility functions (particularly in ``django.utils``)