python: method depends on whether param is int or string
<p>Is there a more pythonic way to write <code>__getitem__</code> than the following? The issue is checking type and doing different things depending on the type of the parameter in the call.</p>

<pre><code>class This():
    def __init__(self, name, value):
        self.name, self.value = name, value

class That():
    def __init__(self):
        self.this_list = []
    def add_this(self, this):
        self.this_list.append(this)
    def __getitem__(self, x):
        if isinstance(x, int):
            return self.this_list[x] # could wrap in try/except for error checking
        elif isinstance(x, str):
            for this in self.this_list:
                if this.name == x:
                    return this
            return None


a = This('a', 1)
b = This('b', 2)
c = That()
c.add_this(a)
c.add_this(b)
print c[1].name
print c['a'].name
</code></pre>
