ArgumentParser epilog and description formatting in conjunction with ArgumentDefaultsHelpFormatter

I just tried a multiple inheritance approach, and it works:

class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
    pass

parser = argparse.ArgumentParser(description='test\ntest\ntest.',
                                 epilog='test\ntest\ntest.',
                                 formatter_class=CustomFormatter)

This may break if the internals of these classes change though.

Leave a Comment