Casey wrote: > On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: >> If you can access the argument list manually, you could scan it for a >> negative integer, and then insert a '--' argument before that, >> if needed, before passing it to getopt/optparse. Then you wouldn't have >> to worry about it on the command line. >> >> Cheers, >> Cliff > > Brilliant! > > <code> > # Look for the first negative number (if any) > for i,arg in enumerate(sys.argv[1:]): > # stop if > if arg[0] != "-": break > # if a valid number is found insert a "--" string before it > which > # explicitly flags to getopt the end of options > try: > f = float(arg) > sys.argv.insert(i+1,"--") > break; > except ValueError: > pass > </code> >
One person's "brilliant" is another's "kludge". -- http://mail.python.org/mailman/listinfo/python-list