Let's say I Have a main.py and 26 additional Python files called A.py through Z.py.
The 26 files all contain a single function called functionA(),functionB()...functionZ()
I have a variable, let's call it "var" and wanna fire the right function depending on the variable.
Right now my main.py Code looks like this:
from A import functionA
from B import functionB
.
.
.
from Z import functionZ
var = "N";
if var == "A":
functionA()
elif var == "B":
functionB()
.
.
.
elif var == "Z":
functionZ()
However the actual code won't just have 26 functions but over a hundred.
I heard that if..elif..elif is more performance efficient than a switch var:
would be.
However is there any way I could just fire functionvar()
depending on the variable without iterating through all of them one by one? If not, is if...elif...elif...else the most efficient way?