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:
def S(self):
return data['S']
So I can access the data with foo.S
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: foo.E. I want to be able to do any particular collection of statuses without having to change the class itself.
So I'm looking for a way to modify __init__ for MyClass so that I can define
foo = MyClass(status_list = ('S', 'I', 'E', 'R', 'someotherstatus'))
and then I can automatically access foo.someotherstatus. With my current understanding, the only way I can do this is to go into the code of MyClass and explicitly define a method someotherstatus which will return data['someotherstatus'].
foo.data['S']?foo.S(bar)to get information about thoseSindividuals which satisfies some other property.