Using the argparse
module, is it possible to perform multiple actions for a given argument?
Specifically, I'd like to provide a -l
/--list
option with nargs='?'
that will change the behaviour of the program from its main function to one of giving information about all possibilities in a set or about one particular possibility.
Normally there will be a namespace attribute that contains a function to be called after parsing; I would like the -l
option to both change this attribute and optionally store its argument in a different attribute.
Is this possible?