我不明白为什么__init__
被调用了两次,它会产生不同类型的属性?你知道吗
class Test(object):
def __init__(self, dataobj):
self._dataobj = dataobj
print 'called inside test function %s' % type(self._dataobj)
@property
def dataobj(self):
return self._dataobj
Test(locals())
给出:
called inside test function <type 'dict'>
called inside test function <class 'Test'>
这似乎是一个pass-ref/value问题,但我不明白为什么它会给出不同的类型 而且叫了两次。非常感谢!你知道吗
我猜你打错了班级考试的电话。否则你就不会得到那个结果。Test(Test(locals())将生成您得到的结果。你知道吗
相关问题 更多 >
编程相关推荐