Python-Perl Translation

Sean 'Shaleh' Perry shalehperry at attbi.com
Mon Jan 28 20:58:18 EST 2002


On 29-Jan-2002 Ben Ocean wrote:
> 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}:
> 


from cgi.py (which ships as part of python and does a lot of this for you:

if environ.has_key('QUERY_STRING'):
            if qs: qs = qs + '&'
            qs = qs + environ['QUERY_STRING']

environ is passed in as:

def func(environ = os.environ):




More information about the Python-list mailing list