[issue19462] Add remove_argument() method to argparse.ArgumentParser

2020-03-25 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker ___ ___ P

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2020-03-23 Thread paul j3
paul j3 added the comment: I think it can be closed. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2020-03-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: > In order to migrate from optparse to argparse we need to have > an ability to substitute anguments, e.g. remove and then create. It seems to me that the original use case is obsolete. Paul, do you think this issue should be closed? -- nosy: +rh

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2020-03-23 Thread Alexander Hirner
Alexander Hirner added the comment: @paul j3 FWIW, popping optionals from a cache that is maintained in addition to self._actions, makes special conflict handling unnecessary. i.e.: for option_string in a.option_strings: parser._option_string_actions.pop(option_string) --

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2015-09-27 Thread paul j3
paul j3 added the comment: I realized while answering a Stackoverflow question that the resolve method has the pieces for removing an Action from the parser. It removes an existing Action so that the new, conflicting one, can replace it. It's meant to be used with flagged arguments. If `arg1

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-20 Thread paul j3
paul j3 added the comment: f.nargs = '?' f.default = argparse.SUPPRESS f.help = argparse.SUPPRESS may be best set of tweaks to a positional Action `f`. In quick tests it removes `f` from the help, suppresses any complaints about a missing string, and does not put anything in the names

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-20 Thread Artem Ustinov
Artem Ustinov added the comment: It does the trick with optionals but not the positionals. How the positional arguments can be removed/hidden? -- ___ Python tracker ___ _

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-13 Thread paul j3
paul j3 added the comment: `argparse.SUPPRESS` should do the trick. According to the documentation it can be used with `default` and `help` parameters. -- ___ Python tracker __

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-13 Thread Artem Ustinov
Artem Ustinov added the comment: What is the way to 'hide' the argument from being parsed? E.g. we have self.parser.add_argument('foo') in parent class, how can we modify it in child class so that it would not to appear in --help strings and not populated to child's Namespace? -- _

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-01 Thread paul j3
paul j3 added the comment: Just hang on the Action object that the `add_argument` returned, and change its `help` attribute. a = parser.add_argument('--foo', help='initial help') a.help = 'new help' If using a custom parser class and subclass, I'd do something like: self.

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-01 Thread Artem Ustinov
Artem Ustinov added the comment: Paul, essentialy, what i looking for is to replace the 'help' string of the inherited argument with the new one. If you say it could be changed without any effect so what would be the proper way to do it using argparse? Artem -- _

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-11-01 Thread paul j3
paul j3 added the comment: When you add an argument, argparse creates an `Action`, and returns it. It also places that action in various lists (e.g. parse._actions) and dictionaries. A `remove_argument` function would have to trace and remove all of those links. That's a non-trivial task.

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-10-31 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-10-31 Thread Barry A. Warsaw
Changes by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-10-31 Thread Artem Ustinov
Artem Ustinov added the comment: Explicitly substitute, excuse me On 31 Oct 2013 20:11, "Artem Ustinov" wrote: > > Artem Ustinov added the comment: > > We need argparse to raise an error for conflicting options and that's why > we need to implicitly substitute an option when we need it > On 31

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-10-31 Thread Artem Ustinov
Artem Ustinov added the comment: We need argparse to raise an error for conflicting options and that's why we need to implicitly substitute an option when we need it On 31 Oct 2013 19:54, "R. David Murray" wrote: > > R. David Murray added the comment: > > Does conflict_handler='resolve' address

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-10-31 Thread R. David Murray
R. David Murray added the comment: Does conflict_handler='resolve' address your use case? It sounds like it should. -- nosy: +r.david.murray ___ Python tracker ___

[issue19462] Add remove_argument() method to argparse.ArgumentParser

2013-10-31 Thread Artem Ustinov
New submission from Artem Ustinov: In order to migrate from optparse to argparse we need to have an ability to substitute anguments, e.g. remove and then create. In our framework we use the command line utility base class and then inherit the particular tools from it. The parser in base class