Yeah, I have been hearing that people are having troubles converting, but I have only used argparse - got lucky there I guess.
I am thinking just making the function which spits the class out. Maybe not very optimised solution, but simple. Argument parsing in my case is very far from being a bottleneck. > On 27 Nov 2023, at 22:36, Mats Wichmann <m...@wichmann.us> wrote: > > On 11/27/23 13:21, Dom Grigonis wrote: >> Thank you, exactly what I was looking for! >> One more question following this. Is there a way to have a customisable >> action? I.e. What if I want to join with space in one case and with coma in >> another. Is there a way to reuse the same action class? > > I've worked more with optparse (the project I work on that uses it has > reasons why it's not feasible to convert to argparse); in optparse you use a > callback function, rather than an action class, and the change to a callable > class is somewhat significant :-; so I'm not really an expert. > > The question is how you determine which you want to do - then there's no > problem for the action class's call method to implement it. I presume you can > write an initializer class that takes an extra argument, collect that and > stuff it into an instance variable, then use super to call the base Action > class's initializer with the rest of the args > > super().__init__(option_strings=option_strings, *args, **kwargs) > > Hopefully someone else has done this kind of thing because now I'm just > guessing! > > -- https://mail.python.org/mailman/listinfo/python-list