4

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?

3
  • Why? That's likely to be very irritating for your users. Commented Apr 25, 2015 at 18:39
  • 1
    Your question is almost a duplicate of this one: stackoverflow.com/questions/13075241/… Commented Apr 25, 2015 at 18:39
  • @jonrsharpe I needed it the other day, because I was building a wrapper around some other specialised software. I wanted to keep the flags identical between the wrapper and the software. Commented Apr 25, 2015 at 18:42

1 Answer 1

6
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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.