Next / Previous / Contents / Shipman's homepage

73. WordBank.wordToSlots(): Which slots use a given word?

# - - -   W o r d B a n k . w o r d T o S l o t s

    def wordToSlots ( self, word ):
        '''Return a list of the slots that have this word as a choice

The value returned by Section 73, “WordBank.wordToSlots(): Which slots use a given word?” is a set of words. Just in case the caller plans to modify what we return, we'll use the list() constructor to make a copy of it as a list.

        #-- 1 --
        # [ if word is a key in self.__wordToSlots ->
        #     return a copy of the related list
        #   else -> raise KeyError ]
        return list(self.__wordToSlots[word])