I was looking at the code from this site, for a basic google app engine calculator. I am just as inexperienced with GAE as I am with HTML, so when I saw the code bellow I was a little confused. Mostly with the last line </html>""" % (result, buttons))
. What is the % for and how does it relate result and buttons to the html code?
result = ""
try:
result = f[operator](x, y)
except ValueError:
result = "Error: Incorrect Number"
except ZeroDivisionError:
result = "Error: Division by zero"
except KeyError:
pass
# build HTML response
buttons = "".join(["<input type='submit' name='operator' value='"
+ o + "'>" for o in sorted(f.keys())])
self.response.out.write("""<html>
<body>
<form action='/' method='get' autocomplete='off'>
<input type='text' name='x' value='%s'/><br/>
<input type='text' name='y'/><br/>
%s
</form>
</body>
</html>""" % (result, buttons))