understanding sys.argv[]

Peter Hansen peter at engcorp.com
Thu Aug 15 03:32:59 CEST 2002

Don Low wrote:
> OK, so if I understand correctly, I'd have something like this
> opts, args = getopt.getopt(sys.argv[1:], "i:")
> Not sure why 2 variables (opts and args) get initialized with getopt...

But you *did* read the documentation first, right?  :)

http://www.python.org/doc/current/lib/module-getopt.html tells all...

I quote:
   "The return value consists of two elements: the first is a list 
    of (option, value) pairs; the second is the list of program arguments 
    left after the option list was stripped (this is a trailing slice of args)."

In context that is even clearer...


More information about the Python-list mailing list