[portland] Interating Tuples Through a List
Rich Shepard
rshepard at appl-ecosys.com
Tue Mar 11 17:56:23 CET 2008
On Mon, 10 Mar 2008, kirby urner wrote:
> Note that if you're trying to do a sort within sort, you can do like
> a database key (m, n), where m, n are your two fields.
Kirby, et al.:
I thought of a clearer way to explain what I'm trying to do; I hope that
you'll see where I got stuck and can get me going again in the right
direction.
I have a list of tuples. Each tuple has 17 fields in the range [0,16].
What I need to do is this:
For each component (item[3]):
For each subcomponent (item[2]):
For each variable (item[1]):
For each term (item[0] in range [1,item[16]):
draw axes
plot the curve for each term (item[4), in sequential order (item[5])
by calling the plotting function and passing appropriate parameters
(other items)
next term
close axes (set up for next multicurve plot)
next variable
next subcomponent
next component
Here's the non-working (as intended) code:
for row in self.appData.tsets:
curComp = row[3]
tb.textOut(row[3]) # print component name
tb.x += 9
for s in row:
curSub = s[2]
if s[2] == '':
tb.x += 36
tb.textOut(curSub) # print subcomponent name
tb.x += 9
print s
for v in s:
curVar = v[1]
print curVar
tb.textLine(curVar) # print variable name
# set up for plotting
But, 's' is not what I thought it should be. Therefore, I need to learn
how to properly code these nested loops so that all values in the tuple are
present in each loop.
Rich
--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
More information about the Portland
mailing list