[portland] Two Indices, One For Loop?
Rich Shepard
rshepard at appl-ecosys.com
Tue Apr 22 00:24:30 CEST 2008
On Mon, 21 Apr 2008, Matt McCredie wrote:
> It's not clear to me what labelList and itemList look like. I'm assuming
> something like this:
>
> labelList = ["label_0","label_1","label_2","label_3","label_4","label_5","label_6","label_7","label_8","label_9","label_10","label_11"]
> itemList = [
> [ row0_item0, row0_item1, row0_item2, row0_item3, row0_item4,
> row0_item5, row0_item6, row0_item7, row0_item8, row0_item9,
> row0_item10, row0_item11,],
> [ row1_item0, row1_item1, ...],
> ....
> ]
>
> If that is the case, you can do something like this:
That's the case, Matt.
> for row in itemList:
> for label, item in zip(labelList, row):
> write(label)
> write(item)
> write("\n")
That's essentially the same as regular nested for loops. Does it have
specific advantages?
Many thanks,
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