On Mar 17, 11:48 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle escreveu:> On Mar 17, 9:31 pm, Paulo da Silva <[EMAIL > PROTECTED]> wrote:
[snip] > Thanks. This works exactly the way you wrote. > Yet I am misunderstanding something. Can't pickle "see" that being > MyDate derived from date it also has to look at variables from date? > When do I need to do this? I am using pickle with a lot more complex > classes without this problem. Without the MyDate.__reduce__ method, Python uses the datetime.date.__reduce__ method to pickle your MyDate instances, then it uses MyDate.__new__ to unpickle them. But your MyDate.__new__ method does not understand the format of a pickled date. You could also change the MyDate.__new__ method so that it does understand it, but it wouldn't be that easy as you want it to accept a string, and this is the format that dates are pickled in. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list