On Thu, Feb 21, 2013 at 9:05 PM, Santosh Kumar <sntshkm...@gmail.com> wrote: > parser.add_argument( > 'install', > nargs='?', > help='install myapp' > ) > > parser.add_argument( > 'uninstall', > nargs='?', > help='uninstall myapp' > ) > > args = parser.parse_args()
What you've done is make your program expect arguments, not options. Try running your script --help and you'll see how it parses. Whatever keyword is given goes into args.install, and if you provide a second arg, it'll become args.uninstall. To do what you're looking for there, I wouldn't bother with argparse at all - I'd just look at sys.argv[1] for the word you're looking for. Yes, it'd be a bit strict and simplistic, but by the look of things, you don't need sophistication. ChrisA -- http://mail.python.org/mailman/listinfo/python-list