Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09f4414

Browse files
committed
Expand the LBYL glossary entry.
1 parent 401edd6 commit 09f4414

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Doc/glossary.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ Glossary
392392
the :term:`EAFP` approach and is characterized by the presence of many
393393
:keyword:`if` statements.
394394

395+
In a multi-threaded environment, the LBYL approach can risk introducing a
396+
race condition between "the looking" and "the leaping". For example, the
397+
code, ``if key in mapping: return mapping[key]`` can fail if another
398+
thread removes *key* from *mapping* after the test, but before the lookup.
399+
This issue can be solved with locks or by using the EAFP approach.
400+
395401
list
396402
A built-in Python :term:`sequence`. Despite its name it is more akin
397403
to an array in other languages than to a linked list since access to

Doc/whatsnew/3.2.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ Example of calling the parser on a command string::
112112

113113
>>> cmd = 'deploy sneezy.example.com sleepy.example.com -u skycaptain'
114114
>>> result = parser.parse_args(cmd.split())
115-
116-
>>> # parsed variables are stored in the attributes
117115
>>> result.action
118116
'deploy'
119117
>>> result.targets

0 commit comments

Comments
 (0)