这里是我的,哈哈类使用`object`实例化自定义类
class haha(object):
def theprint(self):
print "i am here"
>>> haha().theprint()
i am here
>>> haha(object).theprint()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters
为什么haha(object).theprint()
得到错误的输出?
你在期待'哈哈(对象)'做什么? – BrenBarn
OP令人困惑的继承与实例化 – inspectorG4dget
虽然这是一个新手问题,但我认为作者正在尝试一个很好的问题,这是一个可以理解的混淆。在我的书中,不是一个downvote的理由。 –