On Tue, Feb 06, 2007 at 12:02:36PM +0200, Maxim Veksler wrote: > > I was reading denyhosts: > """ > (opts, getopts) = getopt.getopt(args, 'f:c:dinuvps?hV', > ["file=", "ignore", "verbose", > "debug", > "help", "noemail", "config=", > "version", > "migrate", "purge", "daemon", > "sync", > "upgrade099"]) > """ > > Python docs doesn't give much help either[1]. man getopt - nada useful.
I don't program in Python, but the standard getopt syntax says that there two kinds of options. Those that take parameters and those that are binary switches. So "f" takes a parameter, and so does "c". "dinuvps?hV" are switches. I assume that the array after it are keyword parameters instead of single characters. In PERL, calling getopts with arguments of "-f test -c 2 -d -i -?" would set opt_f to "test", opt_c to "2", and opt_d, opt_i, and opt_? to something that would be true in a true/false comparison. The rest would remain undefined. Being an old assembly language programer, I always set the variables first, so my code would have been: opt_f = ""; opt_c = ""; opt_d = 0; getopts(); and so on. I also assume that the position of the words in the word array have to match the letter options, and the equal sign is the same as a colon. Note that case matters, so you can have a string of letters such as vVdD and so on. Except for a correspondence with the word forms, the postion in the arrary does not matter, so you can also have: abcdefgABCDEFG or anything else. Geoff. -- Geoffrey S. Mendelson, Jerusalem, Israel [EMAIL PROTECTED] N3OWJ/4X1GM IL Voice: (07)-7424-1667 Fax ONLY: 972-2-648-1443 U.S. Voice: 1-215-821-1838 Visit my 'blog at http://geoffstechno.livejournal.com/ ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
