Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Method to remove argument by name #262

Open
vvch opened this issue Jan 7, 2022 · 1 comment
Open

[feature request] Method to remove argument by name #262

vvch opened this issue Jan 7, 2022 · 1 comment

Comments

@vvch
Copy link

vvch commented Jan 7, 2022

Method to remove argument by name.

Seems useless at first glance, but may be very helpful when there is a bunch of similar programs which inherit from each other.
E. g.

class Program1:
    def __init__(self):
        self.argparser = ArgumentParser(...)
        self.argparser.add()
        ...
        self.argparser.add()  #  lots of arguments

    def run(self):
        args = self.argparser.parse()
        #  Program workflow
        ...

class Program2(Program1):
    def __init__(self):
        super().__init__()
        self.argparser.add('additional argument specific to Program2 only')
        self.argparser.remove('argument useless in Program2')  #  <-- method to be added

It would be useful to have official API to do this trick.

@bw2
Copy link
Owner

bw2 commented Jan 26, 2022

Unless / until more people request this, perhaps you can implement it by creating your own subclass of ConfigArgParse (or by accessing internal data structures like self._actions)?

(If you do, please post it here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants