comple list slices
- From: William Meyer <wmmeyer@xxxxxxxxx>
- Date: Tue, 28 Feb 2006 14:14:04 +0000 (UTC)
Hi,
I have a list of rows which contains a list of cells (from a html table), and I
want to create an array of logical row groups (ie group rows by the rowspan). I
am only concerned with checking the rowspan of specific columns, so that makes
it easier, but I am having trouble implementing it in python. In perl/c I could
use a for loop and modify the control variable as I walked the array:
my (@rowgroups);
for (my ($i) = 0; $i < $#rows; $i++) {
my ($rowspan) = $rows[$i][0]->attr("rowspan") || 1;
$rowspan--; # 0 indexed
push @rowgroups, $rows[$i .. $i+$rowspan];
$i += $rowspan;
}
but in python I can only come up with this:
rowgroups = []
rowspan = 0
for i in rows:
if rowspan > 0:
rowspan -= 1
continue
rowspan = rows[j][0]["rowspan"] or 1
rowgroups.append(rows[ rows.index(i) : rows.index(i) + rowspan ])
rowspan -= 1
I really dont like this solution. Any ideas?
.
- Follow-Ups:
- Re: comple list slices
- From: johnzenger
- Re: comple list slices
- From: shandy . b
- Re: comple list slices
- Prev by Date: Deleting items from Tix Tree
- Next by Date: Re: Python and Flash
- Previous by thread: Deleting items from Tix Tree
- Next by thread: Re: comple list slices
- Index(es):