def write(selfline)pass save_stdout sys stdout sys stdout silent(tryresult func(*argsfinallysys stdout save_stdout return result send print to dummy object which has write method try to return func result but always restore stdout def dumpstatepage(exhaustive= )""for debuggingcall me at top of cgi to generate new page with cgi state details ""if exhaustivecgi test(show page with formenvironetc elsepageheader(kind='state dump'form cgi fieldstorage(show just form fields names/values cgi print_form(formpagefooter(sys exit(def selftest(showastable=false)make phony web page links [(texturl{parms})('text 'urlroot 'page cgi'{' ': })('text 'urlroot 'page cgi'{' ': ' ':' '})('text 'urlroot 'page cgi'{' ':' '' ':' < & '' ':'?'})('te 'urlroot 'page cgi'{'':''' ':''' ':none})pageheader(kind='view'if showastablepagelisttable(linkselsepagelistsimple(linkspagefooter(if __name__ ='__main__'selftest(len(sys argv when runnot imported html goes to stdout web scripting trade-offs as shown in this pymailcgi is still something of system in the makingbut it does work as advertisedwhen it is installed on remote server machineby pointing browser at the main page' urli can check and send email from anywhere happen to beas long as can find machine with web browser (and can live with the limitations of prototypein factany machine and browser will dopython doesn' have to be installed anewand don' need pop or smtp access on the client machine itself that' not the case with the pymailgui client-side program we wrote in this property is especially useful at sites that allow web access but restrict more direct protocols such as pop email web scripting trade-offs