python - answered my own question

Thomas, Mark Mark.Thomas@hit.cendant.com
Fri, 25 Aug 2000 13:59:43 -0400


Lucas,

Here's something I did recently in Python to parse a command line.

    try:
        opts, args = getopt.getopt(sys.argv[1:], 'bf:h')
    except getopt.error, msg:
        usage('getopt error: ' + str(msg))

    for o, a in opts:
        if o == '-h':
            print __doc__
            return
        if o == '-b':
            foo = 1
        if o == '-f':
            bar = a

Cheers.
-- 
Mark "T.C." Thomas
Systems Engineer
Cendant HIT
mark.thomas@hit.cendant.com

-----Original Message-----
From: Lucas Vogel [mailto:lvogel@exponent.com]
Sent: Friday, August 25, 2000 10:39 AM
To: plug1
Subject: python - answered my own question


import sys

f = sys.argv[1] #first argument after script name

-------------------------------------------
Lucas Vogel, Software Developer
LandWarrior Project
Exponent Inc.
lvogel@exponent.com
phone:	(623)587-6739
fax:		(623)587-4187
------------www.exponent.com---------------