Python-Perl Translation

Ben Ocean zope at thewebsons.com
Tue Jan 29 02:35:23 CET 2002


Hi;
I need to translate the following perl code into python:

#!/usr/bin/perl
($user_id,$banner_id,$page) = split(/&/,$ENV{QUERY_STRING});
$redirect = 
"http://www.myaffiliateprogram.com/u/$user_id/t.asp?id=$banner_id&p=$page";
print "Location: $redirect\n\n";
exit;

I have this, but as you can see, I don't know what to substitute for 
$ENV{QUERY_STRING}:

import string
import urllib

x = string.split("$ENV{QUERY_STRING}","&")
user_id = x[0]
banner_id = x[1]
page = x[2]
urlopen(http://www.myaffiliateprogram.com/u/$user_id/t.asp?id=$banner_id&p=$page)

What do I do on the $ENV thing and how does the rest of the code look?
TIA,
BenO






More information about the Python-list mailing list