pythonオプション処理

ちょっと python を使ってみる.

オプション処理.


#!/usr/bin/env python

import optparse
cmdl_usage = 'usage: %prog [options] file'
cmdl_version = '0.1'
cmdl_parser = optparse.OptionParser(usage=cmdl_usage, version=cmdl_version, conflict_handler='resolve')
cmdl_parser.add_option('-h', '--help', action='help', help='print this help text and exit')
(cmdl_opts, cmdl_args) = cmdl_parser.parse_args()
cmdl_parser.print_help()