passing arguments

James Stroud jstroud at mbi.ucla.edu
Fri May 20 18:46:53 EDT 2005


import sys

try:
  arg1 = sys.argv[1]
except IndexError:
  print "This script takes an argument, you boob!"
  sys.exit(1)

OR, way better: See the optparse module.


On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote:
> I'm sure this is obvious, but how the heck do pass an argument(s) to a
> python script from the command line?
>
> Thanks,
>
> Jeff Elkins

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list