Skip to content

Instantly share code, notes, and snippets.

@MozyOk
Created June 4, 2018 16:27
Show Gist options
  • Save MozyOk/160eb565cbc6599dc4de965c1ff204f7 to your computer and use it in GitHub Desktop.
Save MozyOk/160eb565cbc6599dc4de965c1ff204f7 to your computer and use it in GitHub Desktop.
python argument parser
arguments = argparse.ArgumentParser(add_help=False, allow_abbrev=False)

ArgumentParser オブジェクト

class argparse.ArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=argparse.HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)(原文)
新しい ArgumentParser オブジェクトを生成します。すべての引数はキーワード引数として渡すべきです。各引数についてはあとで詳しく説明しますが、簡単に言うと:
add_help - -h/--help オプションをパーサーに追加する (デフォルト: True)
allow_abbrev - 長いオプションが先頭の 1 文字に短縮可能 (先頭の文字が一意) である場合に短縮指定を許可する。(デフォルト: True)

などなど。 つまりは myscript -h myscript -messagemyscript -m できるってな感じ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment