"Marco Lierfeld" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello there,
>
> I want to save an instance of a class containing a dictionary with the
> pickle-module.
>
> The class looks like this:
> class subproject:
> configuration = {}
> build_steps = []
> # some functions
> # ...
>
> Now I create an instance of this class, e.g.
> test = subproject()
> and try to save it with pickle.dump(test, file('test.pickle','wb')) or
> with
> pickle.Pickler(file('test.pickle','wb')).save(test)
I'm guessing that configuration and build_steps are supposed to be instance
variables, not class-level variables. It would be interesting to see what
your __init__ method looks like. I'm guessing you assign something the
self.build_steps in __init__, but self.configuration is omitted.
Try moving these initializers into the __init__ method, as:
class subproject:
def __init__(self):
self.configuration = {}
self.build_steps = []
and see if pickle starts behaving better.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list