def _args_for_opt_dest_subset(option_parser, args, dests=None):
 values = deepcopy(option_parser.get_default_values())
 rargs = [x for x in args]
 option_parser.rargs = rargs
 while rargs:
  arg = rargs[0]
  if (arg == '--'):
   del rargs[0]
   return
  elif (arg[0:2] == '--'):
   for item in _process_long_opt(option_parser, rargs, values, dests):
    (yield item)
  elif ((arg[:1] == '-') and (len(arg) > 1)):
   for item in _process_short_opts(option_parser, rargs, values, dests):
    (yield item)
  else:
   del rargs[0]

def _args_for_opt_dest_subset ( option_parser , args , dests = None ) : values = deepcopy ( option_parser . get_default_values ( ) ) rargs = [ x for x in args ] option_parser . rargs = rargs while rargs : arg = rargs [ 0 ] if ( arg == '--' ) : del rargs [ 0 ] return elif ( arg [ 0 : 2 ] == '--' ) : for item in _process_long_opt ( option_parser , rargs , values , dests ) : ( yield item ) elif ( ( arg [ : 1 ] == '-' ) and ( len ( arg ) > 1 ) ) : for item in _process_short_opts ( option_parser , rargs , values , dests ) : ( yield item ) else : del rargs [ 0 ]
see docs for :py:func:args_for_opt_dest_subset() .