understanding python self and init
<p>As might be familiar to most of you, this is from Mark Pilgrim's book DIP, chapter 5</p>

<pre><code>class FileInfo(UserDict):
    "store file metadata"
    def __init__(self, filename=None):
        UserDict.__init__(self)
        self["name"] = filename
</code></pre>

<p>Well I am new to python, coming from basic C background and having confusion understanding it. Stating what I understand, before what I don't understand. </p>

<p>Statement 0: <code>FileInfo</code> is inheriting from class <code>UserDict</code></p>

<p>Statement 1:  <code>__init__</code> is <em>not a constructor</em>, however after the class instantiates, this is <em>the first method</em> that is defined. </p>

<p>Statement2:  <code>self</code> is almost like <code>this</code></p>

<p>Now the trouble: 
as per St1 init is defined as the first function. </p>

<pre><code>UserDict.__init__(self)
</code></pre>

<p>Now within the same function <code>__init__</code> why is the function being referenced, there is no inherent recursion I guess. Or is it trying to override the <code>__init__</code> method of the class <code>UserDict</code> which the class <code>FileInfo</code> has inherited and put an extra parameter(key value pair) of filename and reference it to the filename being passed to <code>__init__</code> method. </p>

<p>I am partly sure, I have answered my question, however as you can sense there is confusion, would be great if someone can explain me how to rule this confusion out with some more advanced use case and detailed example of how generally code is written. </p>
