Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Attributes Class Reference

List of all members.

Public Member Functions

def __init__
def __get__
def __set__

Public Attributes


Private Attributes


Detailed Description

A decorator that converts a function into a lazy property.  The
function wrapped is called the first time to retrieve the result
and than that calculated result is used the next time you access
the value::

    class Foo(object):

        def foo(self):
            # calculate something important here
            return 42

.. versionchanged:: 0.5
   cached properties are now optionally writeable.

Definition at line 653 of file

Constructor & Destructor Documentation

def (   self,
  name = None,
  doc = None,
  writeable = False 

Definition at line 670 of file

00671     def __init__(self, func, name=None, doc=None, writeable=False):
00672         self.func = func
00673         self.writeable = writeable
00674         self.__name__ = name or func.__name__
00675         self.__doc__ = doc or func.__doc__

Member Function Documentation

def (   self,
  type = None 

Definition at line 676 of file

00677     def __get__(self, obj, type=None):
00678         if obj is None:
00679             return self
00680         value = obj.__dict__.get(self.__name__, _missing)
00681         if value is _missing:
00682             value = self.func(obj)
00683             obj.__dict__[self.__name__] = value
00684         return value

def (   self,

Definition at line 685 of file

00686     def __set__(self, obj, value):
00687         if not self.writeable:
00688             raise TypeError('read only attribute')
00689         obj.__dict__[self.__name__] = value

Member Data Documentation

Definition at line 674 of file

Definition at line 673 of file

Definition at line 671 of file

Definition at line 672 of file

The documentation for this class was generated from the following file: