【发布时间】:2014-12-25 18:21:07
【问题描述】:
我试图将一个类作为参数发送给一个函数,然后在函数中创建该类的一个对象,并使用该对象。但是,我的尝试导致了错误。
def test(some_class):
x = some_class() # first attempt
x = some_class.__init__() # second attempt
第一次尝试产生了这个错误:AttributeError: Table instance has no __call__ method,第二次产生了这个错误:
TypeError: unbound method __init__() must be called with Table instance as first argument (got int instance instead).
这样做的正确方法是什么?
【问题讨论】:
标签: python function class oop object