<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Michael bridges &lt;micha_el2003@yahoo.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> ALAN GAULD &lt;alan.gauld@btinternet.com&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, 16 June, 2011 1:07:14<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Tutor] using python to write web page<br></font><br><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit;" valign="top">&gt; your python code includes html.<div><br>OK, Now I understand.<br><br>&gt; i write the python only code --&gt; web page
 <br>&gt; [ do not care if it is html, xhtml, java, javascript, or whatever]<br><br>But a "web page" is by definition html.<br>Thats what makes it a web page.<br><br>Most browsers can display plain text too but they will usually <br>mess up the formatting so that it is hard to read. If you want <br>to do that then just create a normal text file.<br><br>But if you want the browser4 to display it with any kind of <br>formatting you must use html, thats all the browser understands.<br><br></div><div>&gt; if i wanted to write html in the python i would just write the html</div><div>&gt; not sure how else the restate, rewrite<br><br>The reasons for writing the html from Python are that you <br>can insert dynamic content into the html, such as names <br>or values from a database, or from another file:<br><br>#####################<br>contentStart = """"<br>&lt;html&gt;&lt;body&gt;<br>&lt;p&gt;Here are the current members of my
 club:&lt;/p&gt;<br>"""<br>contentEnd = """<br>&lt;/body.&lt;/html&gt;"""<br><br>data = ["Eric Idle", "Michael Palin", "Graham Chapman"]<br><br>with open("mywebpage.htm","w") as webpage:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webpage.write(contentStart)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webpage.write("&lt;ul&gt;\n")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for name in data:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webpage.write("&lt;li&gt;%s&lt;/li&gt;" % name)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webpage.write("&lt;/ul&gt;\n")<br>&nbsp; &nbsp; &nbsp;&nbsp; webpage.write(contentEnd)<br>#######################<br><br>Now you can regenerate the web file by just adding names to data.<br>(and you could populate data from a text file or database etc)<br>&nbsp;&nbsp;&nbsp;&nbsp; <br>But if you want that to display sensibly in a web browser you <br>need to use html.<br><br>HTH,<br><br>Alan G.<br><br><br>--- On <b>Wed, 6/15/11, ALAN
 GAULD <i>&lt;alan.gauld@btinternet.com&gt;</i></b> wrote:<br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;"><br>From: ALAN GAULD &lt;alan.gauld@btinternet.com&gt;<br>Subject: Re: [Tutor] using python to write web page<br>To: "Michael bridges" &lt;micha_el2003@yahoo.com&gt;<br>Cc: "tutor@python.org"
 &lt;tutor@python.org&gt;<br>Date: Wednesday, June 15, 2011, 4:54 PM<br><br><div id="yiv162580101"><style type="text/css"><!--#yiv162580101 DIV {margin:0px;}--></style><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><b><span style="font-weight:bold;">From:</span></b> Michael bridges &lt;micha_el2003@yahoo.com&gt;<br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><font size="2" face="Tahoma"><b><span style="font-weight:bold;">To:</span></b> Alan Gauld &lt;alan.gauld@btinternet.com&gt;<br><b><span style="font-weight:bold;">Sent:</span></b> Thursday, 16 June, 2011 0:43:35<br><b><span style="font-weight:bold;">Subject:</span></b> Re: [Tutor] using python to write web page<br></font><br>&gt; i do not want to write html, not in whole or in part, nor in reference.<br>&gt; just 100% python. not from a server.<br><br>The code I showed was 100%
 Python that created an html file <br>that could be opened in a browser without a
 server.<br><br>&gt; i want to write the python only code and have python <br>&gt; only code make the web page that can be read on <br>&gt; any computer with a web browser.<br><br>Thats exactly what my code does.<br><br>&gt; no server use, no server down load, no server at all.<br><br>Thats exactly what my code does.<br><br>&gt; no python interrupter.<br><br>No idea what you mean here?<br>If you mean no Python interpreter how do you expect to&nbsp; <br>execute the python code?<br>If you mean you want to read the resultant file without <br>using Python then.... thats exactly what my code does.<br><br>So does my sample code meet your needs, or is there <br>some other requirement that you haven't explained yet?<br><br><br>--- On Wed, 6/15/11, Alan Gauld &lt;<a rel="nofollow">alan.gauld@btinternet.com</a>&gt; wrote:<br><br>&gt; Python can create html
 files so if you only want to
 create<br>&gt; an html file just do it:<br>&gt; <br>&gt; content = """<br>&gt; &lt;html&gt;&lt;body&gt;<br>&gt; &lt;P&gt;Hello world&lt;/p&gt;<br>&gt; &lt;/body&gt;&lt;/html&gt;"""<br>&gt; <br>&gt; open("myfile.htm","w").write(contents)<br>&gt; <br><br>Alan G<br></div></div>



</div></div></blockquote></div></td></tr></tbody></table></div></div>



</div></body></html>