Abandoned <[EMAIL PROTECTED]> writes:

> import cPickle as pickle
> a="{2:3,4:6,2:7}"
> s=pickle.dumps(a, -1)
> g=pickle.loads(s);
> print g
> '{2:3,4:6,2:7}'
>
> Thank you very much for your answer but result is a string ??

Because you gave it a string.  If you give it a dict, you'll get a
dict:

>>> import cPickle as pickle
>>> a = {1:2, 3:4}
>>> s = pickle.dumps(a, -1)
>>> g = pickle.loads(s)
>>> g
{1: 2, 3: 4}

If your existing database already has data in the "{...}" format, then
eval it only the first time.  Then you'll get the dict which you can
cache thruogh the use of dumps/loads.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to