[issue9399] Provide a 'print' action for argparse

2019-11-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Marking this as closed because there has been no activity or interest for over five years. If anyone wants to revive this and write a PR, feel free to reopen. The core idea is plausible, but this doesn't seem to be a recurring need. -- resolutio

[issue9399] Provide a 'print' action for argparse

2019-08-29 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: bethard -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailin

[issue9399] Provide a 'print' action for argparse

2019-04-27 Thread Mark Lawrence
Change by Mark Lawrence : -- nosy: -BreamoreBoy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue9399] Provide a 'print' action for argparse

2014-07-19 Thread paul j3
paul j3 added the comment: As Steven notes, the patch lacks tests. It also lacks documentation. The 2 things that this class does different from 'version' are - write without passing the text through 'textwrap' - write to a user defined file There is a difference in opinion between Éric and

[issue9399] Provide a 'print' action for argparse

2014-07-16 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +berker.peksag ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue9399] Provide a 'print' action for argparse

2014-07-16 Thread Mark Lawrence
Mark Lawrence added the comment: @Paul what is your take on this, other opinions seem positive? -- nosy: +BreamoreBoy, paul.j3 versions: +Python 3.5 -Python 3.3 ___ Python tracker ___

[issue9399] Provide a 'print' action for argparse

2011-12-15 Thread Denilson Figueiredo de Sá
Changes by Denilson Figueiredo de Sá : -- nosy: +denilsonsa ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue9399] Provide a 'print' action for argparse

2011-02-09 Thread Steven Bethard
Steven Bethard added the comment: Argparse's wrapping behavior is determined by the formatter_class: http://docs.python.org/library/argparse.html#formatter-class Is it reasonable to assume that if you're wrapping your own messages you're already specifying formatter_class=argparse.RawTextHelp

[issue9399] Provide a 'print' action for argparse

2011-02-03 Thread Éric Araujo
Éric Araujo added the comment: Thanks for the new patch. It does not apply cleanly to the py3k branch, but that’s very easily corrected. self.file.write(self.message) self.file.write('\n') Could be replaced by print(self.message, file=self.file) print will use the r

[issue9399] Provide a 'print' action for argparse

2010-12-22 Thread Dennis Malcorps
Dennis Malcorps added the comment: I totally forgot about this patch, sorry... Due to university and another python project I am working on I didn't find the time to look at the test suite. I would really appreciate it if someone else could do this ;-) Anyway, I added the changes proposed by

[issue9399] Provide a 'print' action for argparse

2010-12-22 Thread Éric Araujo
Éric Araujo added the comment: Thinking again about that, what’s wrong with argparse replacing \n with spaces and doing its own line wrapping? -- versions: +Python 3.3 -Python 3.2 ___ Python tracker __

[issue9399] Provide a 'print' action for argparse

2010-11-21 Thread Éric Araujo
Éric Araujo added the comment: sys.std* should not be used as default values in a function definition, because they may be rebound to other objects. The usual idiom is to have None as default value and check it at call time. The patch also needs tests and docs. (FTR, the example for callabl

[issue9399] Provide a 'print' action for argparse

2010-08-01 Thread Steven Bethard
Steven Bethard added the comment: The patch looks basically right. A few minor issues: * "message=None," should probably be "message,", that is, message should not be allowed to default to None - I can't see any use case for this action without a message. I believe this means the body of __ca

[issue9399] Provide a 'print' action for argparse

2010-07-30 Thread Dennis Malcorps
Dennis Malcorps added the comment: Here is a patch that adds a 'write' action to argparse. Usage example: >>> parser = argparse.ArgumentParser() >>> parser.add_argument("--license", action="write", message="This file\nis >>> licensed under \t GPL") >>> parser.parse_args(['--license']) This fil

[issue9399] Provide a 'print' action for argparse

2010-07-29 Thread Steven Bethard
Steven Bethard added the comment: The equivalent to optparse callback is basically to define __call__ in a subclass of Action. Pretty much the same amount of work because they both have complicated parameters. The "callable" I (not fully confidently) proposed would just be a shorthand for de

[issue9399] Provide a 'print' action for argparse

2010-07-29 Thread Dennis Malcorps
Dennis Malcorps added the comment: > parser.add_argument('--license', action='write', message='...', > file=sys.stdout) The ability to redirect the output would be a nice addition. > parser.add_argument('--license', action='call', callable=lambda: > sys.stdout.write(message)) optparse alread

[issue9399] Provide a 'print' action for argparse

2010-07-29 Thread Steven Bethard
Steven Bethard added the comment: Should this print to stdout or stderr? I wonder if the API should allow either, and instead look like: parser.add_argument('--license', action='write', message='...', file=sys.stdout) Where sys.stdout would be the default for the file= argument. The action wo

[issue9399] Provide a 'print' action for argparse

2010-07-29 Thread Georg Brandl
Georg Brandl added the comment: Sounds like a good addition to me. -- assignee: -> bethard nosy: +georg.brandl ___ Python tracker ___ ___

[issue9399] Provide a 'print' action for argparse

2010-07-28 Thread R. David Murray
Changes by R. David Murray : -- nosy: +bethard versions: -Python 2.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue9399] Provide a 'print' action for argparse

2010-07-28 Thread Dennis Malcorps
New submission from Dennis Malcorps : 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 c