3つのキーワード引数を取るクラスメソッドを書き込もうとしています。以前にキーワード引数を使用しましたが、クラス内で機能させることができないようです。次のコード:
def gamesplayed(self, team = None, startyear = self._firstseason,
endyear = self._lastseason):
totalGames = 0
for i in self._seasons:
if((i.getTeam() == team or team == "null") and
i.getYear() >= startyear and i.getYear() <= endyear):
totalGames += i .getGames()
return totalGames
エラーが発生します:
NameError:名前'self'が定義されていません
キーワード引数を取り出して単純な位置引数にすると、問題なく動作します。したがって、私の問題がどこにあるのかわかりません。助けてくれてありがとう。