Pickle problem

Daniel Cuschieri mail at danielcuschieri.com
Wed Jan 2 14:04:36 EST 2008


Hi,

I used code similar to the one at
http://www.onlamp.com/pub/a/python/2006/02/09/ai_decision_trees.html in
order to build an ID3 decision tree using python. I obviously do not want to
rebuild this tree every time i need to use it! so i tried to save it using
pickle, after building it:

>from cPickle import dump
>output = open(path, 'wb')
>dump(self.tree, output, -1)
>output.close()

As soon as I do this, I get the following error:
>dump(self.tree, output, -1)
>cPickle.PicklingError: Can't pickle <type 'function'>: attribute lookup
__builtin__.function failed

How on earth can I solve this!? Rebuilding the tree every time is dumb! I'm
sure there is a work around somehow, but I honestly don't have a clue as to
what this might be!

Any ideas please!?  I'm totally lost and stuck!

Thanks!

Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080102/90b4e173/attachment.html>


More information about the Python-list mailing list