I always hated languages like PHP and JSP and PSP which mix code with HTML. Templates... so good... And there is : print '<tr><td></tr></td>'*len(collection)