]> granicus.if.org Git - python/commitdiff
Expand the LBYL glossary entry.
authorRaymond Hettinger <python@rcn.com>
Fri, 17 Dec 2010 20:19:50 +0000 (20:19 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 17 Dec 2010 20:19:50 +0000 (20:19 +0000)
Doc/glossary.rst
Doc/whatsnew/3.2.rst

index a051fe81b0ec3a4dd344cd2f62733e1f9f61c1bc..4958d3ba2b66cf0e0cf61feedb0f8c3d0259c748 100644 (file)
@@ -392,6 +392,12 @@ Glossary
       the :term:`EAFP` approach and is characterized by the presence of many
       :keyword:`if` statements.
 
+      In a multi-threaded environment, the LBYL approach can risk introducing a
+      race condition between "the looking" and "the leaping".  For example, the
+      code, ``if key in mapping: return mapping[key]`` can fail if another
+      thread removes *key* from *mapping* after the test, but before the lookup.
+      This issue can be solved with locks or by using the EAFP approach.
+
    list
       A built-in Python :term:`sequence`.  Despite its name it is more akin
       to an array in other languages than to a linked list since access to
index 488ad3b460dfc7b98b1d5f34bc3b83d3fc978d51..bb3053dfe0563f8fa2d2cd36b30304a8a03329fb 100644 (file)
@@ -112,8 +112,6 @@ Example of calling the parser on a command string::
 
     >>> cmd  = 'deploy sneezy.example.com sleepy.example.com -u skycaptain'
     >>> result = parser.parse_args(cmd.split())
-
-    >>> # parsed variables are stored in the attributes
     >>> result.action
     'deploy'
     >>> result.targets