Python argparse
In Python, there is no need to write arguments --like_this
.
You can do arguments --like-this
, and argparse will convert the -
characters to _
.
For example:
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument("--like-this", type=int)
>>> args = parser.parse_args("--like-this=123".split())
>>> args
Namespace(like_this=123)
>>> args.like_this
123