diff lookup_list.py @ 300:7c5e5356cb11

doctest syntax for lookup_list
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 09 Jun 2008 13:37:22 -0400
parents cb6b945acf5a
children 32c5f87bc54e
line wrap: on
line diff
--- a/lookup_list.py	Fri Jun 06 17:58:45 2008 -0400
+++ b/lookup_list.py	Mon Jun 09 13:37:22 2008 -0400
@@ -7,21 +7,23 @@
     a dictionary the order of the elements depends not on their key but
     on the order given by the user through construction) so that
     following syntactic constructions work as one would expect::
-       example = LookupList(['x','y','z'],[1,2,3])
-       example['x'] = [1, 2, 3] # set or change a field
-       print example('z','y') # prints [3,2]
-       x, y, z = example
-       x = example[0]
-       x = example["x"]
-       print example.keys() # prints ['x','y','z']
-       print example.values() # prints [[1,2,3],2,3]
-       print example.items() # prints [('x',[1,2,3]),('y',2),('z',3)]
-       example.append_keyval('u',0) # adds item with name 'u' and value 0
-       print len(example) # number of items = 4 here
-       example2 = LookupList(['v', 'w'], ['a','b'])
-       print example+example2 # addition is like for lists, a concatenation of the items.
-       example + example # throw an error as we can't have duplicate name.
+       >>> example = LookupList(['x','y','z'],[1,2,3])
+       >>> example['x'] = [1, 2, 3] # set or change a field
+       >>> print example('z','y') # prints [3,2]
+       >>> x, y, z = example
+       >>> x = example[0]
+       >>> x = example["x"]
+       >>> print example.keys() # prints ['x','y','z']
+       >>> print example.values() # prints [[1,2,3],2,3]
+       >>> print example.items() # prints [('x',[1,2,3]),('y',2),('z',3)]
+       >>> example.append_keyval('u',0) # adds item with name 'u' and value 0
+       >>> print len(example) # number of items = 4 here
+       >>> example2 = LookupList(['v', 'w'], ['a','b'])
+       >>> print example+example2 # addition is like for lists, a concatenation of the items.
+       >>> example + example # throw an error as we can't have duplicate name.
+
     @note: The element names should be unique.
+
     @todo: Convert this documentation into doctest
     format, and actually perform doctest'ing:
     U{http://epydoc.sourceforge.net/manual-epytext.html#doctest-blocks}