The function will be in action
, the string in s
:
args = parser.parse_args()
args.action(args.s)
Note that the declaration of the -s
argument conflicts with the numbered argument s
. You will only see the latter. You should change one of the names—for example change the numbered one to string
, so the short -s
can stay as it is.