Python - Access object attributes as in a dictionary
getattr(my_object, my_str)
Or, if you're not sure if the name exists as a key and want to provide a fallback instead of throwing an exception:
getattr(my_object, my_str, "Could not find anything")
More on getattr.
You can provide support for the []
operator for objects of your class by defining a small family of methods - getitem and setitem, principally. See the next few entries in the docs for some others to implement, for full support.