[issue23298] Add ArgumentParser.add_mutually_dependence_group

2019-04-24 Thread Martin Panter


Change by Martin Panter :


--
superseder:  -> Add "necessarily inclusive" groups to argparse

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2017-01-31 Thread paul j3

paul j3 added the comment:

I propose closing this with reference to http://bugs.python.org/issue11588

--
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-03-22 Thread paul j3

paul j3 added the comment:

http://bugs.python.org/issue11588 is an earlier request for 'necessarily 
inclusive' groups.

The patches that I proposed there are more general, allowing for other logical 
combinations of arguments, as well as nesting groups.  As such it is more 
complex than your patch, but the basic testing idea is the same - 

At the end of _parse_known_args check the group's actions
against the ones that have been parsed.  I use the existing
'seen_actions' or 'seen_nondefault_actions' rather than 
check the namespace directly.

I also tried to construct this testing as a 'hook' that the user could 
customize.

Your test, since it uses the Namespace and Action default, rather than the 
'seen_actions' set, could just as well be run AFTER parse_args.  That's the 
kind of testing that Stackoverflow answers often suggest for similar questions.

In some cases it's also possible to write custom Action classes that handle 
this kind of interdependency.

--
nosy: +paul.j3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23298
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-01-22 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
versions:  -Python 2.7, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23298
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-01-22 Thread R. David Murray

R. David Murray added the comment:

Well, it doesn't make much sense in the English language sense.  If I got that 
error message I'd have no idea what was wrong.

It sounds like what you want to do is dynamically make some arguments be 
required, depending on whether or not other arguments are present or not.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23298
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-01-21 Thread dongwm

New submission from dongwm:

Sometimes I need to use argparse like this:


 parser = argparse.ArgumentParser(prog='PROG')
 group = parser.add_mutually_dependence_group()
 group.add_argument('--foo')
 group.add_argument('--bar')
 parser.parse_args(['--foo', 'f', '--bar', 'b'])
Namespace(bar='b', foo='f')
 parser.parse_args(['--foo', 'f'])
PROG: error: --foo dependence on --bar
 parser.parse_args(['--bar', 'b'])
PROG: error: --bar dependence on --foo

I have some optional argument. but if any argument in a group was present on 
the command line. i need the others must also was present on. so i think 
``add_mutually_dependence_group`` does make sense.

--
components: Library (Lib)
files: argparse_lib.patch
keywords: patch
messages: 234475
nosy: bethard, dongwm
priority: normal
severity: normal
status: open
title: Add ArgumentParser.add_mutually_dependence_group
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file37814/argparse_lib.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23298
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-01-21 Thread dongwm

Changes by dongwm ciici...@gmail.com:


Added file: http://bugs.python.org/file37816/argparse_test.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23298
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-01-21 Thread dongwm

Changes by dongwm ciici...@gmail.com:


Added file: http://bugs.python.org/file37815/argparse_doc.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23298
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com