def set_default_subparser(self, name, args=None):
 subparser_found = False
 for arg in sys.argv[1:]:
  if (arg in ['-h', '--help']):
   break
 else:
  for x in self._subparsers._actions:
   if (not isinstance(x, argparse._SubParsersAction)):
    continue
   for sp_name in x._name_parser_map.keys():
    if (sp_name in sys.argv[1:]):
     subparser_found = True
  if (not subparser_found):
   if (args is None):
    sys.argv.insert(1, name)
   else:
    args.insert(0, name)

def set_default_subparser ( self , name , args = None ) : subparser_found = False for arg in sys . argv [ 1 : ] : if ( arg in [ '-h' , '--help' ] ) : break else : for x in self . _subparsers . _actions : if ( not isinstance ( x , argparse . _SubParsersAction ) ) : continue for sp_name in x . _name_parser_map . keys ( ) : if ( sp_name in sys . argv [ 1 : ] ) : subparser_found = True if ( not subparser_found ) : if ( args is None ) : sys . argv . insert ( 1 , name ) else : args . insert ( 0 , name )
see URL .