a better getopt than getopt.py?

Thomas Sicheritz-Ponten thomas at cbs.dtu.dk
Tue Feb 20 12:29:32 EST 2001


> > this means I have my options defined twice and then once again in the
> USAGE
> > output.  Is there not a better way to handle arguments?
> 

I agree - that is actually the ONLY part I miss from Tcl.  Tcl has this
really nice optparse.tcl package which parses the commandline arguments and
help documentation in one go ...

package require opt
::tcl::OptProc checkopts {
    {file -string      "FASTA file"}
    {-blast -string blastp  "blast program"}
    {-db -string "swiss" "quoted, space seperated list of blast databases"}
    {-flags -string {} "blast flags ( -flags \"\\-hspmax 5\")"}
    {-z "compress"}
    {-subdir "create subdir for each entry"}
    {-html "generate HTML summary"}
    {-grep /opt/gnu/bin/grep "location of GNU's grep"}
    {-report 1 "report \#n hit"}
    {-begin {} "begin with entry"}
    {-rev  "start with last entry"}
    {-switch  "switch order of db and seq ( for non blasts like hmmpfam)"}
} {
    foreach i [info locals] {
        if {$i=="args" || $i=="Args"} continue
        set ::data($i) [ set $i]
    }
}

-thomas

-- 
Sicheritz-Ponten Thomas, Ph.D  CBS, Department of Biotechnology
thomas at biopython.org           The Technical University of Denmark
CBS:  +45 45 252489            Building 208, DK-2800 Lyngby
Fax   +45 45 931585            http://www.cbs.dtu.dk/thomas

	De Chelonian Mobile ... The Turtle Moves ...



More information about the Python-list mailing list