私は質問を繰り返し、答えを促し、最後に結果を格付けするpython関数test()を持っています。 test()関数の代わりにtest()関数に渡したいと思っているのですが、質問を逆順にしたり、質問を逆順にしたり、odds_only() 、私はnameErrorを取得します。私がどこに間違っていたのか理解してくれる人がいらっしゃいますか関数をargとして渡すときのNameError
>>> my.test(mod=shuffle)
... NameError: name 'shuffle' is not defined
def test(self, mod=None):
if mod is not None:
return_value = mod()
def shuffle(self):
list_of_questions = list(self.dictionary.keys())
random.shuffle(list_of_questions)
return list_of_questions
'my'は何ですか? 'test'と' shuffle'はクラスの一部ですか? – kindall
はい、彼らはすべてクラスの一部です、この場合の私はそのクラスのオブジェクトです – GainesvilleJesus