[Tutor] Python Command Line Args (input) equivalent to Perl

Alan Gauld alan.gauld at freenet.co.uk
Thu Oct 28 09:35:56 CEST 2004

> $filename = $ARGV[0];
> open (FILE,"$filename") || die "Can't Open $filename: $!\n";
> while<FILE>{ #dealing with it per-lines
>    #process something here
> }

filename = sys.argv[1]
try: FILE = open(filename)
except: print "Can't open ", filename,"!"; sys.exit(1)
for line in FILE:
   # process line here

> Please also kindly suggest any pointer/website
> link, where I can find Perl-Python concordance,
> especially to facilitate Perl conversion to Python.

Try the archives of the list, someone was askling about 
this very recently.

Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list