Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I replace the built in '-h' action in python using argparse?

I am creating a command line tool in python, and I'm using argparse to parse my input.

I want to use '-h' as an action, but that is already automatically assigned to --help. How can I override this and have an -h action?

like image 549
MCharles Avatar asked Nov 06 '25 08:11

MCharles


1 Answers

parser = argparse.ArgumentParser(add_help=False)

Thanks for asking, because I had the same problem the other day and only bothered checking the documentation now.

like image 91
tommy.carstensen Avatar answered Nov 08 '25 01:11

tommy.carstensen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!