Another stab at a "switch/case" construct (for Python 3000):
Steve Lamb
grey at despair.dmiyu.org
Fri Mar 29 16:11:48 EST 2002
On Fri, 29 Mar 2002 10:48:15 GMT, Benjamin Schollnick <junkster at rochester.rr.com> wrote:
> IF X == 0:
> DO_THIS ()
> ELIF X == 2:
> DO_THIS (2)
> ELIF X == 4:
> DO_THIS (X+2)
> ELIF Y == 6:
> DO_THIS()
> ELIF Z == "ZEBRA":
> DO_THIS ( ZEBRA )
> ELSE:
> DO_NOT_DO_THIS ()
> But, this routine is not exactly readable compared to a case:
> CASE X of:
> 0 : DO_THIS()
> 2 : DO_THIS (2)
> 4 : DO_THIS (x+2)
> 6 : DO_THIS ()
> ELSE:
> DO_NOT_DO_THIS()
its_called_a_directory_pointing_to_functions = {'case':closed}
I do not believe that any language which can have a hash of function
pointers has any business with a case statement.
--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
ICQ: 5107343 | main connection to the switchboard of souls.
To email: Don't despair! | -- Lenny Nero, Strange Days
-------------------------------+---------------------------------------------
More information about the Python-list
mailing list