You try some thing like this:
def print_redirect(url):
print 'Status: 302 Moved Temporarily'
print 'Location:', url
print 'Pragma: no-cache'
print 'Content-Type: text/html'
print
print ''
print '
Redirect (302)'
print '
302 Moved Temporarily
'
print '
The answer to your request is located at'
hurl = cgi.escape(url, 1)
print '%s.' % (hurl, hurl)
note that the url must be absolute.
http://mail.python.org/pipermail/python-list/2001-March/075917.html