def __hasitem__(self, key): if type(key) is int: key in self._by_id else: Title.normalize(key) in self._by_name
def __getitem__(self, key): if type(key) is int: return self._by_id[key] else: return self._by_name[Title.normalize(key)]