1

I have a module that I'm writing an ipython notebook to document. I'd like to have part of that documentation be the response to calling the module from the command line with the --help flag - the parameters set up using argparse. Is there a simple way of getting that as a formatted string?

2 Answers 2

2

Call format_help() on your ArgumentParser instance. It will give you a string with the help text.

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

Comments

0

So what worked in the end is simply using subprocess.check_output as follows:

response = subprocess.check_output('python -m myscript -h')   
print response

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.