En Sun, 08 Feb 2009 14:17:34 -0200, Barak, Ron <ron.ba...@lsi.com> escribió:

I need to copy an instance of a class, where one of the items in the original is a cStringIO.StringO object.
I do not need the cStringIO.StringO in the target object.
The target instance is to be pickled.
[...]
            for_pickle_log_stream = LogStream(sac_log_file)
            for key in log_stream.__dict__:
                if key != "input_file":
                    for_pickle_log_stream[key] = log_stream[key]

Note that you're iterating over __dict__ keys, but the last line does not use __dict__. Either put __dict__ everywhere, or:
    setattr(for_pickle_log_stream, key, getattr(log_stream, key))

But if you want this copy just to pickle it, follow Christian Heimes advice and define __getstate__ / __setstate__.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to