title: Python overriding __init__
body: <p>I know that plenty of people ask questions on this subject, but I haven't seen my specific one asked. When subclassing you can override <code>__init__()</code> the same way that you can override any other method. My question is why in the example below this doesn't seem to be working correctly:</p>
  
  <pre><code>import random
  class MyRand(random.Random):
      def __init__(self, myvar1, myvar2, x=None):
          # ( ... my code ...)
          super(MyRand, self).__init__(x)
  </code></pre>
  
  <p>Remember that <code>Random</code>'s constructor has the following signature: <code>__init__(self, x=None)</code> where <code>x</code> is an optional seed. I want to keep that feature in my subclass, but also I want to require two mandatory variables, <code>myvar1</code> and <code>myvar2</code>.</p>
  
  <p>However, when you try and instantiate (without a seed) you get an error:</p>
  
  <pre><code>MyRand('var1', 'var2')
  TypeError: seed expected at most 1 arguments, got 2
  </code></pre>
  
  <p>This is because python thinks you want <code>Random</code>'s constructor and passes your two arguments 'var1' and 'var2' as the seed. The seed (which is called from inside <code>Random</code>'s constructor) only wants 1 argument, and so you get an error.</p>
  
  <p>However, if you do</p>
  
  <pre><code>MyRand(myvar1='var1', myvar2='var2')
  </code></pre>
  
  <p>This works, here python understands that you're passing it your two mandatory variables and not passing it the optional seed.</p>
  
  <p>But I think the first case should work too. What's going on?</p>