Created on 2018-07-20 20:34 by ckessler, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Messages (4) |
|
|
msg322034 - (view) |
Author: Chris Kessler (ckessler) |
Date: 2018-07-20 20:34 |
In document https://docs.python.org/2/library/argparse.html#argparse.RawDescriptionHelpFormatter this will fail with NameError: global name 'textwrap' is not defiend >>> parser = argparse.ArgumentParser( ... prog='PROG', ... formatter_class=argparse.RawDescriptionHelpFormatter, ... description=textwrap.dedent('''\ ... Please do not mess up this text! ... -------------------------------- ... I have indented it ... exactly the way ... I want it ... ''')) |
|
|
msg322036 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2018-07-20 20:42 |
Thanks for the report. To make it work, you'll have to import textwrap first. We don't always add all the necessary imports in our code snippets and examples, and we don't need to start adding imports into code examples either. So I'm closing this issue. Thanks again. |
|
|
msg322037 - (view) |
Author: Chris Kessler (ckessler) |
Date: 2018-07-20 21:02 |
Thanks for the quick response! I didnt see it anywhere in the documentation on that page so I assumed it was built in with argparse. Thanks! |
|
|
msg322228 - (view) |
Author: paul j3 (paul.j3) *  |
Date: 2018-07-23 16:00 |
argparse does import 'textwrap', but as '_textwrap', so it could be used with: argparse._textwrap.dedent(...) Importing your own is cleaner. |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:03 |
admin |
set |
github: 78355 |
2018-07-23 16:00:05 |
paul.j3 |
set |
nosy: + paul.j3messages: + |
2018-07-20 21:02:39 |
ckessler |
set |
messages: + |
2018-07-20 20:42:30 |
Mariatta |
set |
status: open -> closednosy: + Mariattamessages: + resolution: not a bugstage: resolved |
2018-07-20 20:34:50 |
ckessler |
create |
|