How to initialize an instance using pickle()?
<p>I want to define a class that is able to populate itself reading from the serialized data of another instance. Here's the simplified code:</p>

<pre><code>class MyClass(list):

    def __init__(self,**kwargs):
        if kwargs.has_key('fdata'):
            f = open(kwargs['fdata'],'r')
            self = pickle.load(f)
            print len(self)    #prints 320          
            f.close()              

    ...

a = MyClass(fdata='data.dat')
print len(a)    #prints 0
</code></pre>

<p>This is the output I obtain:</p>

<pre><code>320
0
</code></pre>

<p>The problem I have is that the instance returned is always empty, even though I am able to read all the elements inside <code>__init__()</code> What can be causing this?</p>
