标签: python oop class static-variables
在Python中,如果我有类似的东西:
class A(object): b = B() class B(object): a = A()
会产生错误NameError: name 'B' is not defined
NameError: name 'B' is not defined
你会如何优雅地解决这个问题?
答案 0 :(得分:3)
尝试:
class B(object): pass class A(object): b = B() B.a = A()