After having tested the proposed solutions, i have to curb my
"90%" enthousiasm a little.
All solutions work if you provide an argument that has been "foreseen",
like in a menu system.
But all select...case constructs end with the "case else.." , the alternative for the non-explicitely mentioned values.
I don't see any other solution then a try...except clause, with the risk of not being able to differentiate
between a genuine "bug" or an unexpected value.
All this puzzels me, and there must be some site when you can recommend "improvements" to python.
I'm interested in the historical records, to see if some form of select case has been proposed, and why it's absent.
Maybe it's in the "pipeline" :-)
Paul
"PEP" is what i was looking for, but i did not get any wiser.
Anyway:
There seems to be a solution for the "switch case" or "select case" construction that provides a
"case else" or a "default:
https://data-flair.training/blogs/python-switch-case/
Does not take away that you always find "partial" solutions, and not a generic python solution,
so you can mix single, multiple and range arguments;
I immediately add that single and multiple arguments, such as posts #3 and #8 are possible
because you can use #8 with just 1 value in the tuple. Looks a bit strange, but it works.
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'.