Inserting-embedding some html data at the end of a .py file

Νίκος Γκρ33κ nikos.gr33k at gmail.com
Tue Mar 5 19:53:25 CET 2013


Let's focus on just the following snipper please:

f = open( some_python_file )
		
htmldata = f.read()
counter = ''' print( "
			      <center><a href="mailto:support at superhost.gr"> <img src="/data/images/mail.png"> </a>
			      <center><table border=2 cellpadding=2 bgcolor=black>
					  <td><font color=lime>Αριθμός Επισκεπτών</td>
					  <td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
			      " )
			  ''' % data[0]	
	
#render template				
template = htmldata + counter
print ( template )
=============================

What this snippet tries to accomplish is append the following string

=========================================
		counter = ''' <center><a href="mailto:support at superhost.gr"> <img src="/data/images/mail.png"> </a>
			      <center><table border=2 cellpadding=2 bgcolor=black>
				          <td><font color=lime>Αριθμός Επισκεπτών</td>
					  <td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
			  ''' % data[0
=========================================

at the end of the the python script file that it currently opened.
I'am using the print statemnt inside the triple quoted string so to append that html data by inserting a print statemnt but although i have changes the type of quoting it still fails.

If i try to append that html data to an .html file they are inserted beautifully but inside a .py file they dont.

I just need to append that string after the end of a .py file. that's all i want to do.



More information about the Python-list mailing list