title: How to create dictionary mapping keys to class methods and initialize this object in the same time
body: <p>I'm creating a parser and what I want to do is a method which initializes object of class specified in dictionary and then call method on that class. Objects should be created at run-time, other every time this method is called. It's quite complicated, I think some pseudocode will explain it better:</p>
  
  <pre><code># some_method places intialized object in some list    
  
  dictionary_map = { 'foo': Bar.some_method, 'foo2': Bar2.some_method }
  
  def parse_lines(lines):
      for line in lines:
          for key in dictionary_map: 
              if line.startswith(key):  # checking if line matches dict value
                  dictionary_map[key](line)
  </code></pre>
  
  <p>I know I can pass 'self' argument like this:</p>
  
  <pre><code>f = Bar()
  dictionary_map['foo'](f)
  </code></pre>
  
  <p>But that's not what I want to do. Dictionary is quite big and has many classes in it. I've tried something like this:</p>
  
  <pre><code>dictionary_map = { 'foo': Bar.some_method(object.__new__(Bar)) }
  </code></pre>
  
  <p>But just from looking at it I already know it's not how it should be :)</p>