[Tutor] Translating to Python

Kyle Babich Kyle Babich" <kb@kb5.org
Mon, 1 Jul 2002 21:08:21 +0000


Could someone show me how to translate this to python from perl?

#!/usr/bin/perl -wT
use strict;
use CGI qw/ :standard /;

print header ( 'text/html' );

my $c = param('c');
my $content = "c";
	if ($c eq "abc") {
		$content = qq{abc123};
	} elsif ($c eq "def") {
		$content = qq{def456};
	} else {
		print "error:  content failed\n";
	}

open(TEXT,"text.txt") or die ("error:  text.txt failed\n");
	my $text = <TEXT>;
close(TEXT) or die("error:  close text.txt failed\n");

print <<"EndOfHTML";

$content

<br>&nbsp;<br>&nbsp;<br>&nbsp;

$text

EndOfHTML

And/or could someone recomend a good python tutorial from the ground up
that includes opening external files and if/elseif statements?

Thank you in advance,
Kyle