title: Python optional, positional and keyword arguments
body: <p>This is a class I have:</p>
  
  <pre><code>class metadict(dict):
      def __init__(self, do_something=False, *args, **kwargs)
          if do_something:
              pass
          super(metadict,self).__init__(*args,**kwargs)
  </code></pre>
  
  <p>The idea is to encapsulate a dictionary and add some functionality with a special keyword. The dictionary can still hold <code>do_something</code> though you can't add it at creation time. For all other aspects it behaves just like a normal dictionary.</p>
  
  <p>Anyway, the problem is that whatever I give to <code>args</code> it starts by assigning the first value to <code>do_something</code> which is not what I want.</p>
  
  <p>What I do now is this:</p>
  
  <pre><code>class metadict(dict):
      def __init__(self, do_something=False, *args, **kwargs)
          if not isinstance(do_something, bool):
              args = list(args)
              args.append(do_something)
          elif do_something:
              pass
          super(metadict,self).__init__(*args,**kwargs)
  </code></pre>
  
  <p>But it doesn't look right to me. I could also check for the <code>do_something</code> value in kwargs, but it will be worse, since I mess with the signature removing useful information...</p>
  
  <p>Is there any way in python to use optional, positional and keyword arguments safely?
  If not  are there other simpler workarounds?</p>
  
  <p>I'm on python 2.6</p>