[Checkins] SVN: zope.cachedescriptors/trunk/src/zope/cachedescriptors/property.txt use the doctest syntax

Christian Zagrodnick cz at gocept.com
Wed Jan 20 03:25:58 EST 2010


Log message for revision 108294:
  use the doctest syntax
  

Changed:
  U   zope.cachedescriptors/trunk/src/zope/cachedescriptors/property.txt

-=-
Modified: zope.cachedescriptors/trunk/src/zope/cachedescriptors/property.txt
===================================================================
--- zope.cachedescriptors/trunk/src/zope/cachedescriptors/property.txt	2010-01-20 05:01:33 UTC (rev 108293)
+++ zope.cachedescriptors/trunk/src/zope/cachedescriptors/property.txt	2010-01-20 08:25:57 UTC (rev 108294)
@@ -11,7 +11,7 @@
 
 Cached properties cache their data in _v_ attributes, so they are
 also useful for managing the computation of volatile attributes for
-persistent objects. Let's look at an example::
+persistent objects. Let's look at an example:
 
     >>> from zope.cachedescriptors import property
     >>> import math
@@ -28,32 +28,32 @@
 
     >>> point = Point(1.0, 2.0)   
 
-If we ask for the radius the first time::
+If we ask for the radius the first time:
 
     >>> '%.2f' % point.radius
     computing radius
     '2.24'
 
-We see that the radius function is called, but if we ask for it again::
+We see that the radius function is called, but if we ask for it again:
 
     >>> '%.2f' % point.radius
     '2.24'
 
 The function isn't called.  If we change one of the attribute the
-radius depends on, it will be recomputed::
+radius depends on, it will be recomputed:
 
     >>> point.x = 2.0
     >>> '%.2f' % point.radius
     computing radius
     '2.83'
 
-But changing other attributes doesn't cause recomputation::
+But changing other attributes doesn't cause recomputation:
 
     >>> point.q = 1
     >>> '%.2f' % point.radius
     '2.83'
 
-Note that we don't have any non-volitile attributes added::
+Note that we don't have any non-volitile attributes added:
 
     >>> names = [name for name in point.__dict__ if not name.startswith('_v_')]
     >>> names.sort()
@@ -72,7 +72,7 @@
 store their data using their attribute name, thus overriding
 themselves. This provides much faster attribute access after the
 attribute has been computed. Let's look at the previous example using
-lazy attributes::
+lazy attributes:
 
     >>> class Point:
     ... 
@@ -86,25 +86,25 @@
 
     >>> point = Point(1.0, 2.0)   
 
-If we ask for the radius the first time::
+If we ask for the radius the first time:
 
     >>> '%.2f' % point.radius
     computing radius
     '2.24'
 
-We see that the radius function is called, but if we ask for it again::
+We see that the radius function is called, but if we ask for it again:
 
     >>> '%.2f' % point.radius
     '2.24'
 
 The function isn't called.  If we change one of the attribute the
-radius depends on, it still isn't called::
+radius depends on, it still isn't called:
     
     >>> point.x = 2.0
     >>> '%.2f' % point.radius
     '2.24'
 
-If we want the radius to be recomputed, we have to manually delete it::
+If we want the radius to be recomputed, we have to manually delete it:
 
     >>> del point.radius
 
@@ -113,14 +113,14 @@
     computing radius
     '2.83'
 
-Note that the radius is stored in the instance dictionary::
+Note that the radius is stored in the instance dictionary:
 
     >>> '%.2f' % point.__dict__['radius']
     '2.83'
 
 The lazy attribute needs to know the attribute name.  It normally
 deduces the attribute name from the name of the function passed. If we
-want to use a different name, we need to pass it::
+want to use a different name, we need to pass it:
 
     >>> def d(point):
     ...     print 'computing diameter'
@@ -136,7 +136,7 @@
 ~~~~~~~~~~~~
 
 readproperties are like lazy computed attributes except that the
-attribute isn't set by the property::
+attribute isn't set by the property:
 
 
     >>> class Point:
@@ -160,7 +160,7 @@
     '2.24'
 
 But you *can* replace the property by setting a value. This is the major
-difference to the builtin `property`::
+difference to the builtin `property`:
 
     >>> point.radius = 5
     >>> point.radius
@@ -171,7 +171,7 @@
 ~~~~~~~~
 
 The `cachedIn` property allows to specify the attribute where to store the
-computed value::
+computed value:
 
     >>> class Point:
     ... 
@@ -193,13 +193,13 @@
     '2.24'
 
 The radius is cached in the attribute with the given name, `_radius_attribute`
-in this case::
+in this case:
 
     >>> '%.2f' % point._radius_attribute
     '2.24'
 
 When the attribute is removed the radius is re-calculated once. This allows
-invalidation::
+invalidation:
 
     >>> del point._radius_attribute
 



More information about the checkins mailing list