FW: Switch statements again
Mike Meyer
mwm at mired.org
Thu Jan 16 12:28:17 EST 2003
Carl Banks <imbosol at vt.edu> writes:
> Personally, the elifs don't bother me in the least. In Python, the
> switches are likely to make indentation a pain; it's not clear whether
> case tags should be indented or not. If they are, you have two
> indentation levels for the code inside. If they aren't, you've broken
> a fundamental property of indentation.
Why does not indenting the case tags break a fundamental property of
indentation? Why is something like (using syntax suggested in PEP
275):
when my_value:
# Can we do something useful with this?
in (...):
code
in (...):
more code
else:
yet more code
Any worse than:
if my_value in (...): code
elif my_value in (...):
more code
else:
more code
I don't see a real problem with the first case.
And yes, I like the when ... in syntax suggestion.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list