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中定义数据表的方式。
我想这样做:
TestRetrievalOfClass(Subscriber)
or TestRetrievalOfClass("Subscriber")
谢谢, 尼尔·沃尔特斯
我用的内德密码有点变化。这是一个web应用程序, 因此,我通过URL:http://localhost:8080/TestSpeedRetrieval运行get例程来启动它。我不认为需要初始化。
输出:
如果直接传递类对象,如代码中的“like this”和“or”, 您可以将其名称作为
__name__
属性。从名称开始(如代码中的在“或”之后)会使检索类对象变得非常困难(而且不明确),除非您有一些关于类对象可能包含在哪里的指示——那么为什么不传递类对象呢?!
相关问题 更多 >
编程相关推荐