(self, key)
Dictionary style indexing.
Dictionary style indexing.
Dictionary style indexing .
def __getitem__(self, key):
        """Dictionary style indexing."""
        if self.list is None:
            raise TypeError("not indexable")
        found = []
        for item in self.list:
            if item.name == key: found.append(item)
        if not found:
            raise KeyError(key)
        if len(found) == 1:
            return found[0]
        else:
            return found
def __getitem__ ( self , key ) : if self . list is None : raise TypeError ( "not indexable" ) found = [ ] for item in self . list : if item . name == key : found . append ( item ) if not found : raise KeyError ( key ) if len ( found ) == 1 : return found [ 0 ] else : return found