FW: Switch statements again

David K. Trudgett dkt at registriesltd.com.au
Wed Jan 15 22:30:57 EST 2003


On Wednesday 2003-01-15 at 18:21:40 -0500, Steven Scott wrote:
> Quoting Steven Scott <Steven.Scott at Synchrologic.com>:
> > 
> > If/elif/else remains the most common method.  If Python ever gains
> > something
> > like a switch statement you can bet the farm it won't have a "fall thru"
> > feature though, so the way you've coded your C switch statement wouldn't
> > work.
> > 
> 
> but the absolute /only/ reason you'd use a switch over an if (besides
> looking better) is fall through.

Pascal has no fall though on its case statement, but presumably Wirth
thought it was still worth it. A hundred elifs in a row is just plain
ugly, anyway. Python should get a case/switch statement, just as Perl
6 is going to get one. Leaving it out of both languages to begin with
was misguided. (At least Perl has always had better ways around the
problem than Python.)

David Trudgett







More information about the Python-list mailing list