[portland] Nested for loops, 4 levels deep

Dylan Reinhardt python at dylanreinhardt.com
Wed May 21 02:43:29 CEST 2008

On Tue, May 20, 2008 at 4:33 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> and here are a few tuples from appData.rules:
> [(u'Wildlife', u'Fish', u'Abundance', u'WFA1', u'if abundance is few then
> goodness is very not increased'), (u'Wildlife', u'Fish', u'Abundance',
> u'WFA2', u'if abundance is moderate then goodness is not increased'),
>  Does this provide the data you want? If not, I'll try again.

Let's assume it does... :-)

If I understand correctly, you want the data to lay out something like this:

                       WFA1         if abundance is few then...
                       WFA2         if abundance is moderate then...
                       WFA3         if abundance is many then...

Assuming that to be the case, what about:

for v in varList:
    if row[0] == v[2] and s[1] == v[3]:
        subitems = [tuple(item[-2:]) for item in varList if item[:3] == v[:3]]
        for item in subitems:
           ivr.write('\t%s\t%s\n' % item)

Untested, obviously... but maybe that's close enough to be useful?



More information about the Portland mailing list