I have a function containing other functions. These function are called based on value of variable action
.
These sub functions are logically grouped - i.e., they all deal with file manipulation.
Each function has 2 to 5 lines.
I would like to improve the style.
Is there a more concise way of achieving this end than what I have below? I feed there is a log of defining functions that contain not many LOC.
def my_function(action):
return { '1': func_a, '2': func_b, '3': func_c, '4': func_d}.get(action, err)()
def func_a():
...
...
return ...
def func_b():
...
...
...
return ...
def func_c():
...
...
return ...
def func_d():
...
...
return ...
def err():
return
*discaimer: actual functions have logical names.
My issue is with the proliferation of functions to define
action
is taken from user input for example); I believe the OP issue is with the proliferation of functions to define. – Martijn Pieters Jan 15 at 16:14