[Python-checkins] r83810 - python/branches/release31-maint/Doc/tutorial/datastructures.rst

raymond.hettinger python-checkins at python.org
Sun Aug 8 03:32:07 CEST 2010


Author: raymond.hettinger
Date: Sun Aug  8 03:32:06 2010
New Revision: 83810

Log:
Issue #4570:  Clean-up tutorial example

Modified:
   python/branches/release31-maint/Doc/tutorial/datastructures.rst

Modified: python/branches/release31-maint/Doc/tutorial/datastructures.rst
==============================================================================
--- python/branches/release31-maint/Doc/tutorial/datastructures.rst	(original)
+++ python/branches/release31-maint/Doc/tutorial/datastructures.rst	Sun Aug  8 03:32:06 2010
@@ -377,16 +377,12 @@
 
 Here is a brief demonstration::
 
-   >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
-   >>> fruit = set(basket)               # create a set without duplicates
-   >>> fruit
-   {'orange', 'pear', 'apple', 'banana'}
-   >>> fruit = {'orange', 'apple'}       # {} syntax is equivalent to [] for lists
-   >>> fruit
-   {'orange', 'apple'}
-   >>> 'orange' in fruit                 # fast membership testing
+   >>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
+   >>> print(basket)                      # show that duplicates have been removed
+   {'orange', 'bananna', 'pear', 'apple'}
+   >>> 'orange' in basket                 # fast membership testing
    True
-   >>> 'crabgrass' in fruit
+   >>> 'crabgrass' in basket
    False
 
    >>> # Demonstrate set operations on unique letters from two words


More information about the Python-checkins mailing list