rurpy the second added the comment: Additional comment loosely related to the ParagraphFormatter offered in previous comment...
[If this is not the right venue -- perhaps a new issue or one of the python mail lists would be better -- please tell me.] I notice that argparse.ArgumentParser requires a class (as opposed to instance) for the formatter_class parameter. A cursory look at argparse gives me the impression that this is only so that ArgumentParser can instantiate the instance with a 'prog' argument. If ArgumentParser accepted a HelpFormatter object (rather than a class), then a user could instantiate a custom formatter class with arguments that would customize its behavior. For example, I would be able to write a single ParagraphFormatter class that was instantiated like formatter = ParagraphFormatter (multiline=False) or formatter = ParagraphFormatter (multiline=True) If one has other requirements, perhaps apply one kind of formatting to description/epilogue text and another to the arguments text, then there is an even greater multiplicity of classes that could be avoided by instantiating a single formatter class with arguments. So why can't ArgumentParser look at the formatter_class value: if it's a class proceed as now, but if it's an class instance, simply set its ._prog attribute and use it as is: def _get_formatter(self): if isinstance (self.formatter_class, <type type>): return self.formatter_class(prog=self.prog) else: self.formatter_class._prog = prog return self.formatter_class Of course the "formatter_class" parameter name would then require a little explanation but that's what documentation is for. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12806> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com