Can someone fix my code (Part II)
bovinesoft at my-deja.com
bovinesoft at my-deja.com
Sat Feb 5 00:30:38 EST 2000
When I last posted to this newsgroup, I had a problem and I think I
fixed it (Thanks to all who helped!). Now, however, I am having new
difficulties on my new code. The error message that I got from the code
below was: "NameError: where_temp". If anyone can help me out, I would
be greatly appreciative. Thanks again!
import sys # to use the exit() function
def ssi_or_exit():
sorx = raw_input("Would you like to generate HTML <g> or exit <x>? ")
if sorx == "g": # if they want to generate a web page
body_path = raw_input("Please type the path of the body section:
")
body = open(body_path, "r") # open the text of the web page body
body2 = body.readlines() # body2 is the body text variable
temp_path = raw_input("Please type the path of the HTML template:
")
temp = open(temp_path, "r") # open the HTML template
temp2 = temp.readlines() # temp2 is the template text variable
new_path = raw_input("Please type the path of the new HTML file:
")
new = open(new_path, "w") # create new file at the specified path
where_temp = raw_input("Put the template before <b> or after <a>
the body? ")
ssi()
elif sorx == "x": # if they want to exit
sys.exit("Thank you for using Bovine No Server SSI!")
def ssi():
if where_temp == "b": # for template before body
for line in temp2:
new.write(line)
for line in body2:
new.write(line)
elif where_temp == "a": # for body before template
for line in body2:
new.write(line)
for line in temp2:
new.write(line)
body.close()
temp.close()
new.close()
ssi_or_exit()
ssi_or_exit()
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list