code: def complete(self, text, state):
          
          if text != self.text:
              self.matches = self.completelist(text)
              self.text = text
          try:
              return self.matches[state]
          except IndexError:
              return None
docs: The actual completion method
          
          This method is not meant to be overridden. Override the
          completelist method instead. It will make your life much easier.
          
          For more detail see documentation for readline.set_completer