[portland] Clue Stick Needed
Dylan Reinhardt
dylanr at dylanreinhardt.com
Thu Jan 17 01:03:24 CET 2008
You're using the variable "i" in two different loops here. That's probably
not going to do what you intend.
In any event, you're probably better off iterating through items in a
collection rather than iterating over the index of a size.
Ex:
for row in dataset:
foo = row[3]
rather than
for i in range(len(dataset)):
foo = dataset[i][3]
HTH,
Dylan
On 1/16/08, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>
> On Wed, 16 Jan 2008, Rich Shepard wrote:
>
> > What I need to do is go through the list of rows and isolate the
> items,
> > in sequential order, grouped by names. In C I would write 'for i=0,
> > i<row[16], i++', but what I thought would be the Python equivalent, 'for
> i
> > < row[16]', is not valid. If I try a nested while loop, it hangs on the
> > first item of the first variable.
>
> I think that I'm making progress, but I'm still not there. Here's the
> relevant portion of the function:
>
> proper = lambda t: (t[3],t[2], t[1], t[0], t[5])
> sorted(self.appData.tsets, key=proper)
> for i in range(len(self.appData.tsets)):
> row = self.appData.tsets[i]
> # select component, subcomponent, variable names
> curComp = row[3]
> curSub = row[2]
> curVar = row[1]
> tb.textOut(row[3])
> tb.x += 9
> if row[2] == '':
> tb.x += 36
> tb.textOut(curSub)
> tb.x += 9
> tb.textLine(curVar)
> for i in range(7):
> if i == row[16]:
> print curVar, row[0], row[5], row[4]
>
> This throws no errors, but the resulting list is still not in order:
>
> FloodControl Poor 1 Left Shoulder
> FloodControl Average 2 Trapezoid
> AnimalRefugia Poor 1 Left Shoulder
> AnimalRefugia High 3 Right Shoulder
> FloodControl High 3 Right Shoulder
> AnimalRefugia Adequate 2 Trapezoid
>
> The third FloodControl should follow the second one. Is my syntax error
> obvious?
>
> 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
> _______________________________________________
> Portland mailing list
> Portland at python.org
> http://mail.python.org/mailman/listinfo/portland
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/portland/attachments/20080116/5fbcf168/attachment.htm
More information about the Portland
mailing list