This issue derives from this Stack Overflow question. In that question, the user creates an option that takes two arguments. He can apply a convert operation, but it only applies to the option; it isn't argument-specific. So he can't convert two arguments in different ways.
The workaround provided by the answer is to use a hidden index and a sequence of functions to allow the single function to behave differently for different arguments. But it only works "by accident"; that is, it only works so long as argparse converts arguments in-order and only once per argument.
It might be better to have a more robust solution to this problem. Perhaps convert could take multiple functions, and if you provide such, it applies them to the arguments in-order.
I agree, if an array of functions is passed to convert it should apply them to corresponding arguments. Similar idea is used with argname property already.
This issue derives from this Stack Overflow question. In that question, the user creates an option that takes two arguments. He can apply a
convert
operation, but it only applies to the option; it isn't argument-specific. So he can't convert two arguments in different ways.The workaround provided by the answer is to use a hidden index and a sequence of functions to allow the single function to behave differently for different arguments. But it only works "by accident"; that is, it only works so long as argparse converts arguments in-order and only once per argument.
It might be better to have a more robust solution to this problem. Perhaps
convert
could take multiple functions, and if you provide such, it applies them to the arguments in-order.