argparse: identify which subparser was used [duplicate]
A simpler solution is to add dest to the add_subparsers call. This is buried a bit further down in the documentation: […] If it is necessary to check the name of the subparser that was invoked, the dest keyword argument to the add_subparsers() call will work In your example replace: subparsers = parser.add_subparsers(help=’commands’) with: subparsers … Read more