defaultdicts pickling
Yoav Goldberg
yoav.goldberg at gmail.com
Sat Jul 14 12:03:01 EDT 2007
Hello,
I need to have a dictionary of dictionaries of numbers, and I would like the
dictionaries to be defaultdicts, because it makes the code much nicer
(I want to be able to do: d['foo']['bar']+=1 ).
So naturally, I used:
d = defaultdict(lambda :defaultdict(int))
It works great, but now I can not pickle it.
I could ofcourse used a real function and not a lambda, but this would make
things (a) somewhat slower and (b) a bit ugly.
Is there another way of achieving the same behaviour, that allow for
pickling?
Thanks,
Yoav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070714/79a0b203/attachment.html>
More information about the Python-list
mailing list