[Python-checkins] r87344 - in python/branches/py3k/Doc: glossary.rst whatsnew/3.2.rst

raymond.hettinger python-checkins at python.org
Fri Dec 17 21:19:50 CET 2010


Author: raymond.hettinger
Date: Fri Dec 17 21:19:50 2010
New Revision: 87344
Log:
Expand the LBYL glossary entry.
Modified:
 python/branches/py3k/Doc/glossary.rst
 python/branches/py3k/Doc/whatsnew/3.2.rst
Modified: python/branches/py3k/Doc/glossary.rst
==============================================================================
--- python/branches/py3k/Doc/glossary.rst	(original)
+++ python/branches/py3k/Doc/glossary.rst	Fri Dec 17 21:19:50 2010
@@ -392,6 +392,12 @@
 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
Modified: python/branches/py3k/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/3.2.rst	(original)
+++ python/branches/py3k/Doc/whatsnew/3.2.rst	Fri Dec 17 21:19:50 2010
@@ -112,8 +112,6 @@
 
 >>> 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


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /