liveBook · Manning

Help message

As explained in Tiny Python Projects: Learn coding and testing with puzzles and games

A help message is command-line documentation printed by a program to explain its invocation syntax and available arguments or options.

A help message is command-line documentation that explains a program’s invocation syntax and available arguments or options. Programs commonly display it for -h or --help, helping users change behavior without editing source code. section 1.7

A useful help message typically shows:

  • A usage line describing required positional arguments and optional flags. section 1.7
  • A short program description and explanations for each argument or option. section 16.1 section 17.1
  • Validation feedback when required arguments are missing or files cannot be opened. section 1.7 section 7.1

A generated help message

With argparse, defining a required name argument and a description lets hello.py respond to ./hello.py -h with a usage line, the “Say hello” description, the name argument, and the standard -h, --help option. section 1.7

$ ./hello.py -h
usage: hello.py [-h] name
 
Say hello
 
:
  name        Name to greet      #1
 
:
  -h, --help  show this help message and exit

Inspect the complete terminal output for a help message, including usage syntax, a positional argument, and the standard help flag. section 1.7

How Tiny Python Projects: Learn coding and testing with puzzles and games covers it

How deep it goes
Explains generated usage output and argument errors through argparse, but does not descend into parser internals.
Examples
Demonstrates hello.py, scrambler.py, mad.py, gematria.py, picnic.py, gashlycrumb.py, and friar.py help output.
What it assumes
Assumes basic Python programs and command-line execution while introducing argparse for parsing arguments and producing documentation.
What you can do after
Apply it via argparse to create documented command-line programs with standard help output and validation feedback.
How it connects
Connects command-line arguments with argparse, positional arguments, optional arguments, usage statements, and file validation.

Also explained in

Compare how 2 books explain help message →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny Python Projects: Learn coding and testing with puzzles and games. The section links point to the parts of the book it draws on.