title: Is it possible to create a new python object with custom methods?
body: <p>So I've got a class in python representing an epidemic simulation.  So in many cases I have an 'S', 'I' and possibly 'R' states (susceptible, infected, recovered).  So I've got something crudely like this method in the class:</p>
  
  <pre><code>def S(self):
      return data['S']
  </code></pre>
  
  <p>So I can access the data with <code>foo.S</code>
  but maybe I'm looking at some other simulation where I've got other statuses (let's say 'E' is also a status (exposed)).  I'd like to be able to automatically get the other data by a similar method: <code>foo.E</code>.  I want to be able to do any particular collection of statuses without having to change the class itself.</p>
  
  <p>So I'm looking for a way to modify <code>__init__</code> for <code>MyClass</code> so that I can define </p>
  
  <pre><code>foo = MyClass(status_list = ('S', 'I', 'E', 'R', 'someotherstatus'))
  </code></pre>
  
  <p>and then I can automatically access <code>foo.someotherstatus</code>.  With my current understanding, the only way I can do this is to go into the code of <code>MyClass</code> and explicitly define a method <code>someotherstatus</code> which will return <code>data['someotherstatus']</code>.</p>