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


Groups > comp.lang.python > #21642

Re: Enchancement suggestion for argparse: intuit type from default

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'foo': 0.09; 'from:addr:python': 0.09; 'case.': 0.15; 'argparse,': 0.16; 'default),': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'intuition': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr :python-list': 0.16; 'roy': 0.16; 'subject:argparse': 0.16; '(i.e.': 0.17; 'wrote:': 0.18; 'int': 0.18; 'seems': 0.20; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; '(or': 0.22; 'true,': 0.29; 'seem': 0.29; 'pm,': 0.29; 'admit': 0.30; 'does': 0.32; 'that,': 0.32; 'header:User-Agent:1': 0.33; 'match': 0.34; 'received:84': 0.34; 'reply-to:addr:python.org': 0.34; 'problem.': 0.35; 'to:addr:python-list': 0.35; 'but': 0.37; 'using': 0.37; "i'll": 0.38; 'could': 0.38; 'some': 0.38; 'should': 0.38; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'type': 0.61; 'john': 0.61; 'special': 0.66; 'designed': 0.69; 'header:Reply- To:1': 0.70; 'presents': 0.71; 'reply-to:no real name:2**0': 0.72; 'article,': 0.84; 'enhancement': 0.96
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=ZZifx7pA c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=qePWxsfFzlIA:10 a=QlRFm4pJbugA:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=mHr6GJ5fAAAA:8 a=8uHJpSbaAAAA:8 a=VGDky_61knRSi56AxVYA:9 a=HHBmPSs4HZ-GgzUnflYA:7 a=wPNLvfGTeEIA:10 a=PTLX3WsdNBUA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Thu, 15 Mar 2012 02:10:11 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Enchancement suggestion for argparse: intuit type from default
References <jjocvo$5i2$1@panix2.panix.com> <4f612a9d$0$12033$742ec2ed@news.sonic.net> <roy-5E2425.20522314032012@news.panix.com>
In-Reply-To <roy-5E2425.20522314032012@news.panix.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
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.661.1331777255.3037.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1331777255 news.xs4all.nl 6968 [2001:888:2000:d::a6]:34285
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21642

Show key headers only | View raw


On 15/03/2012 00:52, Roy Smith wrote:
> In article<4f612a9d$0$12033$742ec2ed@news.sonic.net>,
>   John Nagle<nagle@animats.com>  wrote:
>
>>  On 3/13/2012 2:08 PM, Roy Smith wrote:
>>  >  Using argparse, if I write:
>>  >
>>  >       parser.add_argument('--foo', default=100)
>>  >
>>  >  it seems like it should be able to intuit that the type of foo should
>>  >  be int (i.e. type(default)) without my having to write:
>>  >
>>  >       parser.add_argument('--foo', type=int, default=100)
>>  >
>>  >  Does this seem like a reasonable enhancement to argparse?
>>
>>      default=None
>>
>>  presents some problems.
>
> I'll admit I hadn't considered that, but I don't see it as a major
> problem.  The type intuition could be designed to only work for types
> other than NoneType.

True, you could consider that a special case.

If you really do want NoneType, or if the type doesn't otherwise match
the default (or there's no default), then you can still be explicit.

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


Thread

Enchancement suggestion for argparse: intuit type from default roy@panix.com (Roy Smith) - 2012-03-13 17:08 -0400
  Re: Enchancement suggestion for argparse: intuit type from default Ben Finney <ben+python@benfinney.id.au> - 2012-03-14 08:35 +1100
    Re: Enchancement suggestion for argparse: intuit type from default Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-14 12:53 +0000
      Re: Enchancement suggestion for argparse: intuit type from default Ben Finney <ben+python@benfinney.id.au> - 2012-03-15 00:19 +1100
        Re: Enchancement suggestion for argparse: intuit type from default Roy Smith <roy@panix.com> - 2012-03-14 09:30 -0400
          Re: Enchancement suggestion for argparse: intuit type from default MRAB <python@mrabarnett.plus.com> - 2012-03-14 17:26 +0000
          Re: Enchancement suggestion for argparse: intuit type from default Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-14 13:03 -0600
  Re: Enchancement suggestion for argparse: intuit type from default rusi <rustompmody@gmail.com> - 2012-03-14 03:22 -0700
  Re: Enchancement suggestion for argparse: intuit type from default Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-03-14 13:26 +0100
  Re: Enchancement suggestion for argparse: intuit type from default John Nagle <nagle@animats.com> - 2012-03-14 16:32 -0700
    Re: Enchancement suggestion for argparse: intuit type from default Roy Smith <roy@panix.com> - 2012-03-14 20:52 -0400
      Re: Enchancement suggestion for argparse: intuit type from default Ben Finney <ben+python@benfinney.id.au> - 2012-03-15 12:22 +1100
        Re: Enchancement suggestion for argparse: intuit type from default Cameron Simpson <cs@zip.com.au> - 2012-03-15 16:59 +1100
        Re: Enchancement suggestion for argparse: intuit type from default Robert Kern <robert.kern@gmail.com> - 2012-03-15 10:06 +0000
          Re: Enchancement suggestion for argparse: intuit type from default Roy Smith <roy@panix.com> - 2012-03-15 09:28 -0400
            Re: Enchancement suggestion for argparse: intuit type from default Cameron Simpson <cs@zip.com.au> - 2012-03-16 08:18 +1100
      Re: Enchancement suggestion for argparse: intuit type from default MRAB <python@mrabarnett.plus.com> - 2012-03-15 02:10 +0000

csiph-web