[Python-Dev] Re: switch statement

Stephen J. Turnbull stephen at xemacs.org
Thu Apr 28 10:42:53 CEST 2005

>>>>> "Guido" == Guido van Rossum <gvanrossum at gmail.com> writes:

    Guido> You mean like this?

    if x > 0:
        ...normal case...
    elif y > 0:
        ....abnormal case...
        ...edge case...

The salient example!  If it's no accident that those conditions are
mutually exclusive and exhaustive, doesn't that code require at least
a comment saying so, and maybe even an assertion to that effect?
Where you can use a switch, it gives both, and throws in economy in
both source and object code as a bonus.

Not a compelling argument---your example shows switches are not
universally applicable---but it's a pretty good deal.

    Guido> You have guts to call that bad style! :-)

Exaggeration in defense of elegance is no vice.<wink>

School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.

More information about the Python-Dev mailing list