I have a string which represents a python dictionary returned from a db table e.g.
{'name': 'John', 'email': '[email protected]'}
where {'name': 'John', 'email': '[email protected]'} is returned as a string from the db
I then have a function which receives a dictionary as **kwargs e.g.
def print_details(*args, **kwargs):
name = kwargs.pop('name', None)
email = kwargs.pop('email', None)
print "%s - %s " % (name, email)
I want to do
dict = DB return value
print_details(dict)
but I don't know how to convert the string dict into a python dictionary
I am using Django but if there is no way in Django then Python would obviously work as well
eval()? What was wrong with that?eval, not only in OP's case ;)eval()? Do tell.