Steve Holden wrote: > Steven Bethard wrote: >> >> Also possible, to guarantee that exactly one argument was given: >> >> try: >> arg1, = sys.argv >> except ValueError: >> print "This script takes an argument, you boob!" >> sys.exit(1) >> > Aren't we forgetting argv[0] here
Oops. Yup. Change all "sys.argv" to "sys.argv[1:]". Sorry, I never use sys.argv directly anymore; I always get my argv through optparse, which kindly strips off sys.argv[0]. Good catch, thanks! STeVe -- http://mail.python.org/mailman/listinfo/python-list