Multiway Branching

rshepard at salmo.appl-ecosys.com rshepard at salmo.appl-ecosys.com
Sun Jan 8 16:43:29 EST 2006


On 2006-01-08, Fredrik Lundh <fredrik at pythonware.com> wrote:

> DATA_MAP = {
>     chr(32)+chr(32): 0,
>     chr(36)+chr(32): "natural",
>     ...
>     chr(32)+chr(1): 5,
>     chr(66)+chr(32): 0.167,
> }
> ...
> row_value = DATA_MAP[source.read(2)]
>
> # or: row_value = DATA_MAP.get(source.read(2), DEFAULT)

  Thank you, Fredrik. That's ideal, and a great lesson for a newcomer to
Python.

Rich

-- 
Richard B. Shepard, Ph.D.               |   Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM)   |  Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com>     Voice: 503-667-4517         Fax: 503-667-8863



More information about the Python-list mailing list