randomState = collections.namedtuple('randomState', ['player', 'score'])
プレーヤー/スコアを含む名前付きタプルがあり、それらの関数のいずれかを置き換える場合は、次のようにします。
def random(state):
return state._replace(score='123')
基本的に名前付きタプルに似た関数を持ち、いずれかのプレーヤー/スコアを手動で置き換えることができるクラスを作成するにはどうすればよいですか?
class Random:
def abc(self, score):
if self.score == '123':
###had it were a namedtuple, I would use the replace function here, but classes don't allow me to do that so how would I replace 'score' manually?
ここで意味があるかどうかはわかりませんが、誰かが私の問題を理解している場合は、フィードバックをいただければ幸いです。ありがとう