Coding Nested Loops

Rich Shepard rshepard at appl-ecosys.com
Fri Sep 15 18:14:13 CEST 2006


   I want to code what would be nested "for" loops in C, but I don't know the
most elegant way of doing the same thing in python. So I need to learn how
from you folks. Here's what I need to do: build a database table of 180
rows. Each row contains 31 columns: the first is an automatically
incremented integer as the primary key; the next two fields can each contain
one of three strings held in dictionaries, the last 28 fields are random
floats from a third dictionary.

   Of the 180 total rows, each of the three values in the first dictionary
will be the second field in 60 rows. Within each set of 60 rows, there will
be 13 rows containing the first value from the second dictionary, 14 rows
containing the second value from the second dictionary, and 33 rows from
the third value in that dictionary. Again, the final 28 fields in each row
are random values from the third dictionary.

   I suspect that iterators might be the way to accomplish this, but I really
don't know. However, I would like to learn so that I can solve similar
problems by myself.

TIA,

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863



More information about the Python-list mailing list