def query_param(self, key, value=None, default=None, as_list=False):
        """
        Return or set a query parameter for the given key

        The value can be a list.

        :param string key: key to look for
        :param string default: value to return if ``key`` isn't found
        :param boolean as_list: whether to return the values as a list
        :param string value: the new query parameter to use
        """
        parse_result = self.query_params()
        if value is not None:
            # Need to ensure all strings are unicode
            if isinstance(value, (list, tuple)):
                value = list(map(to_unicode, value))
            else:
                value = to_unicode(value)
            parse_result[to_unicode(key)] = value
            return URL._mutate(
                self, query=unicode_urlencode(parse_result, doseq=True))

        try:
            result = parse_result[key]
        except KeyError:
            return default
        if as_list:
            return result
        return result[0] if len(result) == 1 else result
def query_param ( self , key , value = None , default = None , as_list = False ) : parse_result = self . query_params ( ) if value is not None : if isinstance ( value , ( list , tuple ) ) : value = list ( map ( to_unicode , value ) ) else : value = to_unicode ( value ) parse_result [ to_unicode ( key ) ] = value return URL . _mutate ( self , query = unicode_urlencode ( parse_result , doseq = True ) ) try : result = parse_result [ key ] except KeyError : return default if as_list : return result return result [ 0 ] if len ( result ) == 1 else result
Return or set a query parameter for the given key

        The value can be a list.

        :param string key: key to look for
        :param string default: value to return if ``key`` isn't found
        :param boolean as_list: whether to return the values as a list
        :param string value: the new query parameter to use