Gets a cached token object or creates a new one if not already cached

def get_token(cls, value):
        "Gets a cached token object or creates a new one if not already cached"

        # Use try/except because after running for a short time most tokens
        # should already be cached
        try:
            return cls._cache[value]
        except KeyError:
            token = Token(value)
            cls._cache[value] = token
            return token