I have a place in my script where I am asking user for some feedback (selecting the next stage in the script) and due to huge amount of items user is making decision from I wrapped my 'if-else' part into a dictionary. I am able to call any 'plain' function, but in a lot of cases I have to call the same function but with some arguments, but cannot figure out how to add these to the body of the script I already have. It looks like this (I will try to comment it so you see where I have a problem):
def runthis():
# getting user input
decide = input(str(
'Select option 1'
'Select option 2'
'Select option 3'
'Select option etc'
'Select option n'))
# each action listed here as a function without parentesis and arguments
options = {
'1': func1,
'2': func2,
'3': func3,
'etc': funcetc,
'n': funcn}
# go through the list and look for key matching user decision
# then run the value as a function - how to pass arguments when I need?
if decide in options.keys():
options[decide]()
else:
print('invalid entry')
runthis()
runthis()
Thanks, any help much appreciated.