Hi,
I came across the following function:
Also when I invoke the file with python3 I get an error on the line:
Could someone explain or provide some context for the use of -> and the error I see?
I came across the following function:
def getWords(self) -> list[str]: with open(self.word_list_path, "r") as f: word_list = [line.strip() for line in f] return word_list class Ui_MainWindow(QMainWindow): def __init__(self, word_list_path: str): super().__init__() self.word_list_path = word_list_path self.speller = SpellCheckWrapper(self.getWords(), self.addToDictionary) self.setupUi() class SpellCheckWrapper: def __init__( self, personal_word_list: list[str], addToDictionary: Callable[[str], None] ): # Creating temporary file self.file = QTemporaryFile() self.file.open() self.dictionary = DictWithPWL( "en_US", .......I am not familiar with the notation "def getWords(self) -> list[str]:" in the function definition. What does the -> mean?
Also when I invoke the file with python3 I get an error on the line:
self.speller = SpellCheckWrapper(self.getWords(), self.addToDictionary)TypeError: 'type' object is not subscriptable
Could someone explain or provide some context for the use of -> and the error I see?