Enchancement suggestion for argparse: intuit type from default

Ben Finney ben+python at benfinney.id.au
Tue Mar 13 17:35:12 EDT 2012


roy at panix.com (Roy Smith) writes:

> 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))
[…]

-0.5.

That feels too magical to me. I don't see a need to special-case that
usage. There's not much burden in being explicit for the argument type.

-- 
 \           “Value your freedom or you will lose it, teaches history. |
  `\     “Don't bother us with politics,” respond those who don't want |
_o__)                            to learn.” —Richard M. Stallman, 2002 |
Ben Finney



More information about the Python-list mailing list