2017-06-06 58 views
1

我正在嘗試構建一個API,使我可以選擇不同的提取和比較方法。每種方法都有自己的一套參數。什麼是最pythonic和最乾淨的方式來做這樣的事情:如何創建一個API來選擇帶參數的函數

class ThisObject(object): 
    def __init__(self, input_file, extraction_method, analyses_method): 
     self.input_file = input_file 

     extracted_info = extraction_method(input_file, **parameters1**) 
     analyzed_info = analyses_method(extracted_info) 


this_object = ThisObject(input_file='~/some_file', 
         extraction_method=extraction_method.get_first_name(**parameters**), 
         analyses_method=analyses_method.get_percent_matrix(**parameters**) 
         ) 

回答

相關問題