Greetings
Question for you. Does python suffer from a lack of switch / case statement in your opinions. I say yes, if / elif is OK but seems very inelegant to me.
Your opinions please.
Mark
Greetings
Question for you. Does python suffer from a lack of switch / case statement in your opinions. I say yes, if / elif is OK but seems very inelegant to me.
Your opinions please.
Mark
I don't personally think that Python suffers from an absence of the Switch-Case statements. The if-elif method is very similar, and though you have to repeatedly state the variable being assessed, you don't need to include break statements.
The if-elseif approach (while not so elegant) can also be applied to many other languages as well, so from an educational point of view it may be more universal.
Paul
Your comment about being if / elif being used in others is a point well made! I just like the use of switch cases in other languages. But of you are going from python onto another such as c++ then you already have a structure that works. But of course going from c++ to python you may, as I have, be used to using cases. Just one of those things I suppose
Paul
Your comment about being if / elif being used in others is a point well made! I just like the use of switch cases in other languages. But of you are going from python onto another such as c++ then you already have a structure that works. But of course going from c++ to python you may, as I have, be used to using cases. Just one of those things I suppose