Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20992

Re: suppressing argparse arguments in the help

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'test,': 0.04; 'suppress': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'symbolic': 0.09; '"normal"': 0.16; 'argparse': 0.16; 'bethard': 0.16; 'clash': 0.16; 'false)': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'safe,': 0.16; 'somewhere?': 0.16; 'subject:argparse': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'arguments': 0.18; 'instance': 0.18; 'help.': 0.19; 'subject:help': 0.21; 'from:addr:web.de': 0.23; 'happen.': 0.23; "shouldn't": 0.23; 'unlikely': 0.23; 'tests': 0.25; "wasn't": 0.25; 'somewhere': 0.26; 'module': 0.26; 'code': 0.26; 'users.': 0.28; 'script': 0.28; 'second': 0.28; 'constant': 0.29; "skip:' 10": 0.29; 'correct': 0.29; 'pm,': 0.29; 'equality': 0.30; 'actually': 0.31; "i've": 0.32; 'instead': 0.33; 'object': 0.33; 'header:X-Complaints-To:1': 0.34; 'checking': 0.34; 'steven': 0.34; 'probably': 0.35; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'but': 0.37; 'some': 0.38; 'should': 0.38; 'that.': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'more': 0.61; 'your': 0.61; 'andrea': 0.84; 'otten': 0.84; 'stems': 0.84; 'want:': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: suppressing argparse arguments in the help
Date Tue, 28 Feb 2012 19:07:02 +0100
Organization None
References <4F4CE7BC.6080908@gmail.com> <jiitoi$6c6$1@dough.gmane.org> <4F4CFD7A.20904@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p50849a89.dip.t-dialin.net
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.247.1330452615.3037.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330452615 news.xs4all.nl 6948 [2001:888:2000:d::a6]:46697
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20992

Show key headers only | View raw


Andrea Crotti wrote:

> On 02/28/2012 04:02 PM, Peter Otten wrote:
>> Andrea Crotti wrote:
>>
>>> I have a script that might be used interactively but also has some
>>> arguments that
>>> should not be used by "normal" users.
>>> So I just want to suppress them from the help.
>>> I've read somewhere that the help=SUPPRESS should do what I want:
>>>
>>>       parser.add_argument('-n', '--test_only',
>>>                           action='store_true',
>>>                           help=SUPPRESS)
>>>
>>> but that's what I get from "myapp -h", which is not exactly what I was
>>> looking for..
>>>
>>>
>>>     -f, --first_level     ==SUPPRESS== (default: False)
>>>     --never_redevelop     ==SUPPRESS== (default: False)
>>>
>>>
>>> Any other solutions?
>> That shouldn't happen. Did you reload() somewhere?
>> argparse tests object identity not equality with SUPPRESS, so you have to
>> ensure that SUPPRESS stems from the same instance of the argparse module
>> as your ArgumentParser.
>>
> 
> Ah great yes it wasn't actually the same..
> but why not just use
> if text != SUPPRESS
> instead of:
> if text is not SUPPRESS

Steven Bethard would have to answer that. 
If it were my code I would have used the equality test, but also the correct 
symbolic constant...
 
> probably the second is more safe, but they are it's still checking
> against a constant that
> is very unlikely to clash with anything..

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: suppressing argparse arguments in the help Peter Otten <__peter__@web.de> - 2012-02-28 19:07 +0100

csiph-web