如果我在Python中运行它
class Boo(object):
def __init__(self, x):
self._x = x
self.__bingo = 3
self._info = {'x': x, 'y':42}
def __dir__(self):
return ['x']
@property
def x(self):
return self._x
@property
def z(self):
return self._x+1
def __getattr__(self, key):
return self._info[key]
b = Boo(44)
b.__dict__.keys()
然后打印
['_info', '_Boo__bingo', '_x']
为什么重命名__bingo
?是否保留双下划线属性?