Python Forum
In ArgParse, can two compatible formatter_class values be used?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In ArgParse, can two compatible formatter_class values be used?
#1
When setting up argparse, I would like to use BOTH formatter_class=argparse.ArgumentDefaultsHelpFormatter AND formatter_class=RawDescriptionHelpFormatter so that the user sees argument default values AND I can code multiline pre-indented "description" and "epilog" values.

If that possible, what is the correct syntax? Or can only one formatter_class value be used?

TIA for any assistance you can provide.

Peter
Reply
#2
Looking into arpgarse's code, we see that ArgumentDefaultsHelpFormatter overrides a single method _get_help_string() and RawDescriptionHelpFormatter overrides only _fill_text(). It may depend on the python version, but I think you could try this
class MyFormatter(ArgumentDefaultsHelpFormatter, RawDescriptionHelpFormatter):
    pass

...formater_class=MyFormatter...
Reply
#3
Thank you very much, that worked flawlessly.

Marking this issue solved.

Peter
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug argparse io issue pyDream 8 696 Apr-02-2024, 12:42 PM
Last Post: pyDream
  Not able to figure out what is wrong with argparse radioactive9 31 8,613 Mar-16-2022, 07:50 PM
Last Post: deanhystad
  argparse --help in one line. Denial 1 2,003 Sep-20-2020, 03:38 PM
Last Post: deanhystad
  Creating Excel files compatible with microsoft access vkallavi 0 1,594 Sep-17-2020, 06:57 PM
Last Post: vkallavi
  Argparse error when inputting values tqader 2 2,891 Sep-11-2020, 07:42 PM
Last Post: buran
  Why this pycharm warning for argparse formatter_class value? pjfarley3 2 2,141 Sep-09-2020, 05:23 AM
Last Post: pjfarley3
  Can argparse support undocumented options? pjfarley3 3 2,224 Aug-14-2020, 06:13 AM
Last Post: pjfarley3
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 4,927 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  Why am I getting KeyError 'file' when using argparse? Mike Ru 1 3,084 Jun-09-2019, 04:48 PM
Last Post: metulburr
  How can I get some arguments using argparse? Mike Ru 0 1,888 Jun-05-2019, 12:57 PM
Last Post: Mike Ru

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020