displaying newlines in the help message when using python's optparse -
i'm using optparse module option/argument parsing. backwards compatibility reasons, can't use argparse module. how can format epilog message newlines preserved?
in below example, i'd epilog printed formatted.
epi = \ """ examples usages: %prog -a -b foo else %prog -d -f -h bar """ parser = optparse.optionparser(epilog=epi)
see first answer at:
python optparse, how include additional info in usage output?
the basic answer subclass optionparser
class myparser(optparse.optionparser): def format_epilog(self, formatter): return self.epilog
Comments
Post a Comment