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


Groups > comp.lang.python > #21640

Re: Enchancement suggestion for argparse: intuit type from default

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!panix!roy
From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: Enchancement suggestion for argparse: intuit type from default
Date Wed, 14 Mar 2012 20:52:23 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Lines 22
Message-ID <roy-5E2425.20522314032012@news.panix.com> (permalink)
References <jjocvo$5i2$1@panix2.panix.com> <4f612a9d$0$12033$742ec2ed@news.sonic.net>
NNTP-Posting-Host localhost
X-Trace reader1.panix.com 1331772744 4982 127.0.0.1 (15 Mar 2012 00:52:24 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Thu, 15 Mar 2012 00:52:24 +0000 (UTC)
User-Agent MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
Xref csiph.com comp.lang.python:21640

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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