Hi,
I knew dict could be used to replace "select... case"... statements, the single biggest thing i missed in Python.
So with the info of post #5, i tried to make something, but it's not quite allright. What is wrong? I get an extra 'None' in the output.
Paul
I knew dict could be used to replace "select... case"... statements, the single biggest thing i missed in Python.
So with the info of post #5, i tried to make something, but it's not quite allright. What is wrong? I get an extra 'None' in the output.
Output:This has plenty of useful applications, e.g. the pythonic way to create a menu/switch statement, using dict with functions as values.
def AAA(): print('AAAxxx') def BBB(): print('BBByyy') def CCC(): print('CCCzzz') aaa = AAA bbb = BBB ccc = CCC myDict = {100:aaa,200:bbb,300:ccc} x = myDict[200]() print(x)Can i do without line 15 ?
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.