![]() If you want to get it as a single string rather than print it out, change each print into yield and use '\n'.join(html_table(lol)). The second half of the problem - produce an HTML table from a list of lists of strings: def html_table(lol): Produces your three desired results (one list per row, not in HTML form yet -). Return for i in range(numrows)]įor example.: L = ![]() Numrows = (len(alist) sublen-1) // sublen Return for i in range(0, len(alist), sublen)]Īnd column-major not that bad: def col_major(alist, sublen): ![]() I think the two tasks are really very distinct and there's nothing to gain (and much to lose) in mushing them up, so I would be astonished if any well-designed library did such mushing.įor point 1, row-major is easy: def row_major(alist, sublen): given a list of sublists with string items, produce an HTML table out of it. ![]() given a "flat list", produce a list of sublists where the sublists are of a given length and the overall list may be walked into either a "row major" order (your first and third example) or "column major" (your second example).I would decompose your problem into two parts:
0 Comments
Leave a Reply. |