class TestSpeedRetrieval(webapp.RequestHandler):
"""
Test retrieval times of various important records in the BigTable database
"""
def get(self):
commandValidated = True
beginTime = time()
itemList = Subscriber.all().fetch(1000)
for item in itemList:
pass
endTime = time()
self.response.out.write("<br/>Subscribers count=" + str(len(itemList)) +
" Duration=" + duration(beginTime,endTime))
如何将上述内容转换为传递类的名称的函数? 在上面的例子中,Subscriber(在Subscriber.all()。fetch语句中)是一个类名,这就是您如何使用Python定义Google BigTable中的数据表。Python:将类名作为参数传递给函数?
我想做的事情是这样的:如果直接传递类对象,如与代码“像这样”和“
TestRetrievalOfClass(Subscriber)
or TestRetrievalOfClass("Subscriber")
感谢, 尼尔·沃尔特斯
酷,我不知道,你可以通过一类,就像任何其他变量。我错过了那个连接。 – NealWalters 2009-09-17 03:37:11
函数,方法,类,模块所有东西都是python中的第一个类对象,你可以通过 – 2009-09-17 05:31:27