I have a program where the user should be able to pick and choose commands from a drop down list. In this list, there is also a repeat command, which does basically what a for loop does, so all the commands in between repeat
and end repeat
should be looped the number of times stated. See picture:
Now, I don't yet know how to programatically handle the repeat-functions. I know that python handles classes like objects, so maybe that can help, but I'm a bit lost.
At the moment I send a list of strings to the thread that handles execution of the commands, and that is parsed and each command is executed.
def command(self, item):
if item.startswith('Pan'):
... do stuff
elif item.startswith('...'):
... do something else
How would I rewrite this so that repeat
is a callable function/method ?