def remove_arg(args, arg, has_param=False):
 for (idx, found_arg) in enumerate(args):
  if (found_arg == arg):
   if has_param:
    slice_idx = (idx + 2)
   else:
    slice_idx = (idx + 1)
   args = (args[:idx] + args[slice_idx:])
   break
 return args

def remove_arg ( args , arg , has_param = False ) : for ( idx , found_arg ) in enumerate ( args ) : if ( found_arg == arg ) : if has_param : slice_idx = ( idx + 2 ) else : slice_idx = ( idx + 1 ) args = ( args [ : idx ] + args [ slice_idx : ] ) break return args
removes the first instance of the specified arg from the list of args .