[Tutor] stuck with html table

alan.gauld@bt.com alan.gauld@bt.com
Wed, 30 May 2001 13:46:38 +0100


> What's wrong with following code?
> 
> def dumptable(table):
>     result1 = ""
>     resutl2 = ""
>     htmlheader = "<html><head></head><body>"
>     htmlfooter = "</body></html>"
>     tablefoot = "</table>"
> 
>     def tablehead(columns):

Indented def? Implies you are on 2.1 since nested 
functions are iffy (IMHO) in earlier versions...

Since I can't really see a goiod reason to use 
them here why not just dedent the nrested functions?

>     return result1 + "</tr>"

Here's the line that returns the /tr
result is not being changed from the initial ""
up to this point. I think this line should be 
indented to be the return value of then nrested 
function???

I really don't like nested functions much, 
unless its for functions that return functions
and for those I'd prefer a real lambda 
- see a previous post! :-)

>     result2 = htmlheader + tablehead(5)
>     for i in table:
>         result2 += tablerow(i)
>     return result2 + tablefoot + htmlfooter

This is never executed because of the return 
above...

Alan G