__main__.py file has a function's flow, based on methods of each class instance, which each one has its own methods and attributes, like this:
from xlrd import open_workbook from pprint import pprint from rubrica_manager import RubricaManager from rectified_rubrica_manager import RectifiedRubricaManager from rectification_spreadsheet_manager import RectificationSpreadsheetManager from gps_manager import GPSManager from sys import exit from data_comparison import DataComparison def main(): ''' Execute PostDiagnosisChecker ''' rm = RubricaManager("File1.xlsx") rrm = RectifiedRubricaManager("File2.xlsx") rsm = RectificationSpreadsheetManager("File3.xlsx") gm = GPSManager("File4.xlsx") object_collection = [rm, rrm, rsm, gm] for current_spreadsheet in object_collection: ''' evaluate each object if it has the method or attribute before executing ''' methods_list = dir(current_spreadsheet) if "load_data" in methods_list.get("load_data"): current_spreadsheet.load_data() if "spreadsheet_to_array" in methods_list: current_spreadsheet.spreadsheet_to_array() if "headers_array" in methods_list: current_spreadsheet.headers_array if "headers_used_indexes" in methods_list: current_spreadsheet.get_used_indexes(0) if "remove_duplicity_by_timestamp" in methods_list: current_spreadsheet.remove_duplicity_by_timestamp() if "array_to_dictionary" in methods_list: current_spreadsheet.array_to_dictionary()
There are methods commonly to all of instances, some of them are not. Because of that, I thought about a way to evaluate if each instance has its respective method, but I don't know if this is the most performative way. Any ideas?
Python version 2.6.