Use jQuery to send a request to your python script on server that will be handled as a CGI/Fast CGI script or through WSGI (mod_wsgi for Apache) or mod_python (for Apache too).
Your Python script will receive input using query strings.
Client side example:
<html><head><title>TEST</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
pyurl = "/cgi-bin/main.py"; // Just for example. It can be anything. Doesn't need to be Python at all
function callpy (argdict) {
$.post(pyurl, argdict, function (data) {
// Here comes whatever you'll do with the Python's output.
// For example:
document.write(data);
});
}
</script>
</head><body>
<!-- Now use it: -->
<a href="#" onclick='javascript:callpy({"s": "bow", "someother": "argument"});'>CLICK HERE FOR TEST!!!</a>
</body></html>
On server side (CGI just for example):
#! /usr/bin/env python
import cgi, cgitb
cgitb.enable()
print "Content-Type: text/html\n"
i = cgi.FieldStorage()
if i.has_key("s"):
if i["s"].value=="bow": print "Yeeeeey!!!! I got 'bow'!!!<br>"
else: print "Woops! I got", i["s"].value, "instead of 'bow'<br>"
else: print "Argument 's' not present!<br>"
print "All received arguments:"
for x in i.keys(): print x, "<br>"