zenlotus / argparse

Automatically exported from code.google.com/p/argparse
Other
0 stars 0 forks source link

Cannot specify 'dest' for positional arguments #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We should be able to control the attribute name of the resulting Namespace
object that positional arguments get mapped to. But currently we cannot:

#! /usr/bin/env python

import argparse

parser = argparse.ArgumentParser()
# following fails
parser.add_argument('pos-arg1', dest="posarg1", help='positional argument 1')
# ValueError: dest supplied twice for positional argument

Original issue reported on code.google.com by jeetsukumaran on 12 Mar 2010 at 12:47

GoogleCodeExporter commented 9 years ago
If you want to specify the attribute name, use the first argument. If you want 
to
customize how it is displayed in help messages, use metavar. E.g.

parser.add_argument('posarg1', metavar='pos-arg1')

Original comment by steven.b...@gmail.com on 12 Mar 2010 at 1:33

GoogleCodeExporter commented 9 years ago

Original comment by steven.b...@gmail.com on 23 Jul 2010 at 1:19