How to add new attributes in argparse

Hello, as a python beginner, when I user argparse to get environment variable from current environment and add more attribute to it, an error occured like follows:

import argparse

args = argparse.ArgumentParser()

args.add_argument('--max_days', default=7, type=int, max_value=30, min_value=1)

where “max_value” and “min_value” are extra, however,

TypeError: init() got an unexpected keyword argument ‘max_value’

my question is: why not add *args and **kwargs into init()? In this case, we can also finish parameter validaiton.

How does argparse know what to do with ‘max_value’? You can do post-processing of the value and raise an error to the user, or implement a custom argparse action class.