[issue34188] Allow dict choices to "transform" values in argpagse

2018-09-22 Thread paul j3
Change by paul j3 : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue34188] Allow dict choices to "transform" values in argpagse

2018-08-18 Thread paul j3
paul j3 added the comment: The 'choices' mechanism is quite simple. As noted for testing it simply uses an 'in' test. For help formating it uses choice_strs = [str(choice) for choice in action.choices] result = '{%s}' % ','.join(choice_strs) In other words, it's treated as a

[issue34188] Allow dict choices to "transform" values in argpagse

2018-08-17 Thread Matthijs Kooijman
Matthijs Kooijman added the comment: One way to make the original example from Victor work, is to use the following action class: class ConvertChoices(argparse.Action):

[issue34188] Allow dict choices to "transform" values in argpagse

2018-08-17 Thread Matthijs Kooijman
Matthijs Kooijman added the comment: I was today trying to achieve something similar. I also considered the solution using `type` argument, but that does not seem to play well with the `choices` argument. I was going to report that as a bug, but this issue seems similar enough to comment

[issue34188] Allow dict choices to "transform" values in argpagse

2018-07-23 Thread paul j3
paul j3 added the comment: The 'choices' mechanism is a simple 'value in choices' test. A dictionary (or other mapping) works because it works with 'in'. 'type' as noted is the means that argparse provides for transforming an input string into some other object (most commonly a number with

[issue34188] Allow dict choices to "transform" values in argpagse

2018-07-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: Victor, please don't try to get your way by adopting a tone of shoving people around or mis-parsing their words try to catch them in a contradiction. There is in fact a boundary between argument parsing logic and application logic. In my view, the

[issue34188] Allow dict choices to "transform" values in argpagse

2018-07-22 Thread Victor Porton
Victor Porton added the comment: @Raymond: "Downstream processing or transformation of inputs is beyond the scope of argparse which should stick to its core responsibilities of argument extraction." You somehow contradict the official documentation: "One particularly effective way of

[issue34188] Allow dict choices to "transform" values in argpagse

2018-07-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Zachary. Downstream processing or transformation of inputs is beyond the scope of argparse which should stick to its core responsibilities of argument extraction. -- assignee: -> bethard nosy: +bethard, rhettinger type: behavior

[issue34188] Allow dict choices to "transform" values in argpagse

2018-07-22 Thread ppperry
Change by ppperry : -- title: Use dicts to "transform" argparse arguments to values -> Allow dict choices to "transform" values in argpagse ___ Python tracker ___