This is probably has a very solution but I am struggling with this a bit. I have 3 almost similar functions I'd like to refactor into one.
Here's the function:
def delete_labels_replication_controller(provider, obj_type):
obj_label_list = []
obj_type_list = provider.mgmt.list_replication_controller()
def delete_labels_node(provider, obj_type):
obj_label_list = []
obj_type_list = provider.mgmt.list_node()
def delete_labels_image(provider, obj_type):
obj_label_list = []
obj_type_list = provider.mgmt.list_image()
Now, as you see, the only thing that changes is the provider.mgmt.xxx class and it changes according to the obj_type I want to pass into the function. Question is how to use only 1 function for all of them and replace only the .xxx part of the object? Thanks!