New submission from Dennis Malcorps <dennis.malco...@googlemail.com>:
Currently argparse has a 'version' action which can be triggered by user defined options which prints out a custom string. parser.add_argument("--version", action="version", version="test 1.2.3") Since the 'version' action can be added multiple times, it can be used to output different kinds of information, like the program's license. parser.add_argument("--license", action="version", version="This file is licensed under GPL.... [a huge amount of text]") The only drawback is that linebreaks are substituted with a normal space. So I propose a 'print' action (perhaps as a replacement for 'version'?) which respects whitespace characters. parser.add_argument("--version", action="print", message="test 1.2.3") parser.add_argument("--license", action="print", message="This file is licensed under GPL.... [a huge amount of text, now properly formatted!]") parser.add_argument("--insult-me", action="print", message="You sick *peep* , *peep* yourself in *peep*") Currently, the only solution is to create a custom action which is IMHO a bit overkill for just printing a simple string to stdout. ---------- components: Library (Lib) messages: 111824 nosy: travistouchdown priority: normal severity: normal status: open title: Provide a 'print' action for argparse type: feature request versions: Python 2.7, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9399> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com