Python: Passing a class name as a parameter to a function?

后端 未结 3 1931
北荒
北荒 2020-12-08 04:27
class TestSpeedRetrieval(webapp.RequestHandler):
  \"\"\"
  Test retrieval times of various important records in the BigTable database 
  \"\"\"
  def get(self):
            


        
3条回答
  •  囚心锁ツ
    2020-12-08 05:02

    class TestSpeedRetrieval(webapp.RequestHandler):
      """
      Test retrieval times of various important records in the BigTable database 
      """
      def __init__(self, cls):
          self.cls = cls
    
      def get(self):
          commandValidated = True 
          beginTime = time()
          itemList = self.cls.all().fetch(1000) 
    
          for item in itemList: 
              pass 
          endTime = time()
          self.response.out.write("
    %s count=%d Duration=%s" % (self.cls.__name__, len(itemList), duration(beginTime,endTime)) TestRetrievalOfClass(Subscriber)

提交回复
热议问题