Message218395
| Author |
paul.j3 |
| Recipients |
GraylinKim, bethard, denilsonsa, eric.araujo, paul.j3, rurpy2, zbysz |
| Date |
2014年05月13日.01:38:46 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1399945127.13.0.661388279597.issue12806@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
An alternative to passing a Formatter instance to the parser is to use a wrapper function. `HelpFormatter.__init__` takes several keyword args. '_get_formatter' does not use those. However we could define:
def format_wrapper(**kwargs):
# class 'factory' used to give extra parameters
def fnc(prog):
cls = argparse.HelpFormatter
return cls(prog, **kwargs)
return fnc
and use that to set the 'width' of the formatter object.
parser = argparse.ArgumentParser( formatter_class = format_wrapper(width=40)) |
|