Simplified notation of condition if/else on python or function / expression

Hello,

You could use a python dictionary as follows (here i have split it over multiple lines separated by commas:

aml_by_xy = {(100,48): (25,16,85),
             (120,48): (36,16,85),
             }
x = 100
y = 48
a, m, l = aml_by_xy[(x,y)]
print a
print m 
print l

25
16
85

This is easier to write, read and edit and will execute much more quickly. I am using tuple unpacking to get the a, m and l values out of the tuple (25, 16, 85)

3 Likes