This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author samwyse
Recipients Ingo.Fischer, bethard, ezio.melotti, samwyse, tshepang
Date 2012-07-14.12:05:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342267516.88.0.973697180146.issue15327@psf.upfronthosting.co.za>
In-reply-to
Content
The Namespace object contains a combined list of all of the arguments, from both the main parser and the subparser.  I don't see any way to resolve identically name augments without breaking a lot of code that relies on the current behavior.  I would instead propose that anyone needing to distinguish between identically named args in nested parsers use distinct names as the primary name of the argument, and the non-distictive name as an alias.  For example:
    parser.add_argument('--verbose(main)', '--verbose', ...)

Running the attached file produces the following output.

# using non-distinctive args
['--verbose', 'command'] => Namespace(command='command', verbose=True)
['command', '--verbose'] => Namespace(command='command', verbose=True)
['--verbose', 'command', '--verbose'] => Namespace(command='command', verbose=True)

# using distinctive args
['--verbose', 'command'] => Namespace(command='command', verbose(main)=True, verbose(subcommand)=False)
['command', '--verbose'] => Namespace(command='command', verbose(main)=False, verbose(subcommand)=True)
['--verbose', 'command', '--verbose'] => Namespace(command='command', verbose(main)=True, verbose(subcommand)=True)
History
Date User Action Args
2012-07-14 12:05:17samwysesetrecipients: + samwyse, bethard, ezio.melotti, tshepang, Ingo.Fischer
2012-07-14 12:05:16samwysesetmessageid: <1342267516.88.0.973697180146.issue15327@psf.upfronthosting.co.za>
2012-07-14 12:05:16samwyselinkissue15327 messages
2012-07-14 12:05:15samwysecreate