def __getitem__(self, key):
        """Dictionary-style lookup by either ID or name"""
        if isinstance(key, _numbers.Integral):
            return self._by_id[key]
        else:
            return self._by_name[key]
def __getitem__ ( self , key ) : if isinstance ( key , _numbers . Integral ) : return self . _by_id [ key ] else : return self . _by_name [ key ]
Dictionary-style lookup by either ID or name