Why can't pickle dump this instance?

Jane Austine janeaustine50 at hotmail.com
Fri Aug 13 01:46:27 EDT 2004


Hi.

class A:
    def __init__(self,tick):
        if tick:
            self.foo=self.bar
        else:
            self.foo=self.bur
    def bar(self):
        print 'bar'
    def bur(self):
        print 'bur'

import pickle
pickle.dumps(A())

running this script results in "TypeError: can't pickle function objects"

Why does this happen? and what can I do?

Jane



More information about the Python-list mailing list