[issue11588] Add "necessarily inclusive" groups to argparse

paul j3 report at bugs.python.org
Wed Feb 26 08:24:09 CET 2014


paul j3 added the comment:

The addition of a simple decorator to the 'ArgumentParser' class, would simplify registering the tests:

    def crosstest(self, func):
        # decorator to facilitate adding these functions
        name = func.__name__
        self.register('cross_tests', name, func)

which would be used as:

    @parser.crosstest
    def pat_or_suf(parser, seen_actions, *args):
        if 2==len(seen_actions.intersection([a_pat, a_suf])):
            parser.error('only one of PATTERN and SUFFIX allowed')

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11588>
_______________________________________


More information about the Python-bugs-list mailing list