例如,如果我们喜欢:
class blah(object):
def __new__(self, **attr):
try: self.isBlah = attr["true_or_false"]
def __init__(self, **attr):
if self.isBlah:
self.blah = self.isBlah
a = blah(true_or_false=True)
print(a.blah)
我知道__new__
一个人先开始,但我们可以给它赋值吗?因为当我在 Python 解释器上执行此操作时,它不会,但在网站编译器中,它会。