Parse a postdata-style response format from the API into usable data

def parse(response):
        """Parse a postdata-style response format from the API into usable data"""

        """Split a a=1b=2c=3 string into a dictionary of pairs"""
        tokens = {r[0]: r[1] for r in [r.split('=') for r in response.split("&")]}

        # The odd dummy parameter is of no use to us
        if 'dummy' in tokens:
            del tokens['dummy']

        """
        If we have key names that end in digits, these indicate the result set contains multiple sets
        For example, planet0=Hoth&x=1&y=-10&planet1=Naboo&x=9&y=13 is actually data for two planets

        Elements that end in digits (like tag0, tag1 for planets) are formatted like (tag0_1, tag1_1), so we rstrip
        underscores afterwards.
        """
        if re.match('\D\d+$', tokens.keys()[0]):
            # Produce a list of dictionaries
            set_tokens = []
            for key, value in tokens:
                key = re.match('^(.+\D)(\d+)$', key)
                # If the key isn't in the format (i.e. a failsafe), skip it
                if key is not None:
                    if key.group(1) not in set_tokens:
                        set_tokens[key.group(1)] = {}

                    set_tokens[key.group(1)][key.group(0).rstrip('_')] = value
            tokens = set_tokens

        return tokens