Is there a way to have
statements = [statement1, statement2, statement3, ...]
in Python?
I want to be able to do:
run statements[i]
or:
f = statements[j] (where f is a function)
P.S. I want to have a list of assignment statements (lambda would not work) and I rather not create functions. For example:
switch = [output = input, output = 2 * input, output = input ** 2]
Is there any other way than defining a function for each entry?
Thank you everyone who answered my question.
statement1 ... statementnin advance (def statement1():...or use lambdas.