Okay let me restructure this to be more theoretical - How do I separate a repetitive task inside a function.
Here is the scenario:
def some_class:
def out_fxn():
self.some_vars being used here
for each value in some dict:
if entry has type_A:
get value, dict_index from entry
some_function(my_dict, dict_key, value)
if entry has type_B:
get value, dict_index from entry
some_function(my_dict, dict_key, value)
if entry has type_C:
get value, dict_index from entry
some_function(my_dict, dict_key, value)
- Class Method? Should some_function(my_dict, dict_index, value) be a method of some_class? It will not use any class member variables and has not much to do with the class as such
- Nested Function? Should some_function(my_dict, dict_index, value) be inside out_fxn()? Nested Function?
Note: I could loop over ABC, assign values accordingly, but I just want to know if there is a way to do this using a function.