def METHOD_NAME(self, optname, args):
    # parse args for this arg
    if self.action == "store":
        if self.nargs is None:
            if args:
                return args.pop(0)
            else:
                raise _ArgError("expecting value for %s" % optname)
        elif self.nargs == "?":
            if args:
                return args.pop(0)
            else:
                return self.default
        else:
            if self.nargs == "*":
                n = -1
            elif self.nargs == "+":
                if not args:
                    raise _ArgError("expecting value for %s" % optname)
                n = -1
            else:
                n = int(self.nargs)
            ret = []
            stop_at_opt = True
            while args and n != 0:
                if stop_at_opt and args[0].startswith("-") and args[0] != "-":
                    if args[0] == "--":
                        stop_at_opt = False
                        args.pop(0)
                    else:
                        break
                else:
                    ret.append(args.pop(0))
                    n -= 1
            if n > 0:
                raise _ArgError("expecting value for %s" % optname)
            return ret
    elif self.action == "store_const":
        return self.const
    else:
        assert False