Most of programming languages out there have switch-case statements. Python
doesn't have support for switch-case statements though. switch-case statements
can sometimes be nice and tidy and sometimes it may be a horrible nightmare.
But that also applies to if-elif-else statements. It would be nice to have
switch-case statements support in python.
Suggested syntax :-
-------------------
switch expr:
case expr2:
case expr3:
statements
default:
statements
How should it be implemented?
-----------------------------------
First of all this will require a new syntax. Second I suggest for comparing the
case expr with switch expr, compare the pointers instead of objects for better
performance. Usually if the ladder is represented using if-elif-else logic then
it would be lower performance because we'll end up comparing objects not
pointers.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/32SKTIZCNJP74ZJSHQ4R2R4A3ODC3LMN/
Code of Conduct: http://python.org/psf/codeofconduct/