My code is here works fine in python2.7
but fails inpython 3
functools.lru_cache(maxsize=32)
any change in from python 2 to python 3.
The error I am getting is for my configparser
object while caching in functools.lru_cache
it says
TypeError: unhashable type: 'ConfigParser'
Want to understand the changes in 'functools.lru_cache'
from python 2 and python 3?
#CONFI FILE
[translate]
api_url = https://url
api_version = version_num
api_key = key_value
#code goes here
import functools
from configparser import ConfigParser as SafeConfigParser
config = SafeConfigParser()
path ="./conf/services.ini"
config.read(path)
@functools.lru_cache(maxsize=32)
def build_api_params_key(config):
"""Build the api url and return with key."""
api_url = config.get('translate', 'api_url')
api_version = config.get('translate', 'api_version')
api_key = config.get('translate', 'api_key')
full_api_url = api_url + api_version
return api_key