code: def is_valid(self, qstr=None):
          
          if not self.help.source_is_console():
              return True
          if qstr is None:
              qstr = self.currentText()
          if not re.search(r'^[a-zA-Z0-9_\.]*$', str(qstr), 0):
              return False
          objtxt = to_text_string(qstr)
          shell_is_defined = False
          if self.help.get_option('automatic_import'):
              shell = self.help.internal_shell
              if shell is not None:
                  shell_is_defined = shell.is_defined(objtxt, force_import=True)
          if not shell_is_defined:
              shell = self.help.get_shell()
              if shell is not None:
                  try:
                      shell_is_defined = shell.is_defined(objtxt)
                  except socket.error:
                      shell = self.help.get_shell()
                      try:
                          shell_is_defined = shell.is_defined(objtxt)
                      except socket.error:
                          # Well... too bad!
                          pass
          return shell_is_defined
docs: Return True if string is valid