类交叉引用?

Max*_*ith 5 c++ python inheritance class

我来自 C++ 背景,如果没有 Python 中的整个指针概念,我有点迷茫。或者至少还不清楚。例如,我想在 Python 中使用 OOP 创建一个滴答声游戏。我有几个这样的课程:

class Game(object):
    def __init__(self, player1, player2):
        self.board = [['','',''],
                      ['','',''],
                      ['','','']]
        self.players = [player1, player2]

class Player(object):
    def __init__(self, game, marking):
        self.game = game
        self.marking = marking  # either 'X' or 'O'
Run Code Online (Sandbox Code Playgroud)

很明显,游戏需要引用两个玩家,而玩家也是游戏的一部分,因此应该引用游戏。但是,上面的代码不起作用,因为如果不先创建游戏,我就无法创建玩家。但是要创建一个游戏,我需要两个玩家。之后我可以通过执行以下操作来添加这些引用:player.game = some_game_reference但这似乎不符合 Python 风格且难以跟上。

完成此任务的最佳和最 Pythonic 的方法是什么?