Closed Sigmanificient closed 1 year ago
It could actually to avoid recomputing the dictionnary, tho it's very small so i think the impact would be minimal
Would you prefer something like this?
def open_cicked_file(self):
return self.open(self.__clicked_file)
openfolder = partial(open, 'folder')
open_file = partial(open, 'file')
menu_select_actions = {
'Open': open_clicked_file,
'Cut': cut,
'Delete': delete,
'Copy': copy,
'Paste': paste,
'Rename': rename,
'New File': open_file,
'New Folder': openfolder,
'Reload': reload,
}
def __perform_menu_selected_action(self, action):
if not action:
return False
action_func = self.menu_select_actions.get(action)
if not action_func:
return False
action_func()
return True
Yes, preferably with __
, because we need them as private at the momment
Yes to hashmaps , but shouldn't
menu_select_actions
be outside of__perform_menu_selected_action
?