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


Groups > comp.lang.python > #21650 > unrolled thread

Re: Enchancement suggestion for argparse: intuit type from default

Started byCameron Simpson <cs@zip.com.au>
First post2012-03-15 21:35 +1100
Last post2012-03-15 21:35 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Enchancement suggestion for argparse: intuit type from default Cameron Simpson <cs@zip.com.au> - 2012-03-15 21:35 +1100

#21650 — Re: Enchancement suggestion for argparse: intuit type from default

FromCameron Simpson <cs@zip.com.au>
Date2012-03-15 21:35 +1100
SubjectRe: Enchancement suggestion for argparse: intuit type from default
Message-ID<mailman.666.1331807597.3037.python-list@python.org>
On 15Mar2012 10:06, Robert Kern <robert.kern@gmail.com> wrote:
| On 3/15/12 5:59 AM, Cameron Simpson wrote:
| > On 15Mar2012 12:22, Ben Finney<ben+python@benfinney.id.au>  wrote:
| > | Roy Smith<roy@panix.com>  writes:
| > |>  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.
| > |
| > | −1, then. It's growing too many special cases, and is no longer simple
| > | to describe, so that indicates it's probably a bad idea.
| >
| > If `type` is not supplied and `default` is present and not None, `type`
| > shall be the type of `default`.
| >
| > That seems straightforward to me. [... sentinels aside...] the `type`
| > should always match type(default). Or am I wrong about that?
| 
| Yes. Not all type(default) types can be called with a string to produce a valid 
| value. Note that "type=" is really a misnomer. argparse doesn't really want a 
| type object there; it wants a converter function that takes a string to an object.

Aha. Still, you could change the docs to say you only need type= if
type(default) _isn't_ useful as the string->value converter.
-- 
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

As your attorney, it is my duty to inform you that it is not important that
you understand what I'm doing or why you're paying me so much money. What's
important is that you continue to do so.
        - Hunter S. Thompson's Samoan Attorney

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web