Expand the LBYL glossary entry.

This commit is contained in:
Raymond Hettinger 2010-12-17 20:19:50 +00:00
parent 401edd69cf
commit 09f44140aa
2 changed files with 6 additions and 2 deletions

View file

@ -392,6 +392,12 @@ Glossary
the :term:`EAFP` approach and is characterized by the presence of many the :term:`EAFP` approach and is characterized by the presence of many
:keyword:`if` statements. :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 list
A built-in Python :term:`sequence`. Despite its name it is more akin 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 to an array in other languages than to a linked list since access to

View file

@ -112,8 +112,6 @@ Example of calling the parser on a command string::
>>> cmd = 'deploy sneezy.example.com sleepy.example.com -u skycaptain' >>> cmd = 'deploy sneezy.example.com sleepy.example.com -u skycaptain'
>>> result = parser.parse_args(cmd.split()) >>> result = parser.parse_args(cmd.split())
>>> # parsed variables are stored in the attributes
>>> result.action >>> result.action
'deploy' 'deploy'
>>> result.targets >>> result.targets