I'm using argparse in Python2.7 and I would like to display multiple lines in the help text of an argument.
My codes look like this:
import argparse
parser = argparse.ArgumentParser(description='details',
usage='use "%(prog)s --help" for more information')
parser.add_argument('--argument', default=None, type=sometype,
help='''
First line \n
Second line \n
\n
More lines \n
''')
I would like to print out the help message in multiple lines when calling --help. However, the output looks as follows.
First line Second line More lines
I know that I could solve the problem by adding up the strings of each line.
parser.add_argument('--argument', default=None, type=sometype,
help='First line \n' +
'Second line \n' +
'\n' +
'More lines')
But there are tens of lines I want to add to the help text. I was wondering is there a convenient way of splitting the help text into multiple lines ?
And also, it seems that there is an upper limit of the number of characters that can be displayed in one line in the help message, which is 54 in my case. Is this limit system-dependent and is there a way to increase the upper limit ?