In article <[email protected]>, Marko Rauhamaa <[email protected]> wrote:
> Neil Cerutti <[email protected]>: > > > Check out Go's switch statement for an example of what it might > > look like in Python. Except you'd get it without labeled break or > > the fallthrough statement. Python already has a switch statement. It's just spelled funny... class Switch(Exception): pass class Case1(Switch): pass class Case2(Switch): pass class Case3(Switch): pass try: raise value except Case1: print "did case 1" except (Case2, Case3): print "did either case 2 or 3" else: print "did default" No fall-through, however. I'm sure with a little meta-class magic, you could write a Case() which eliminates the need for manually declaring the cases. -- https://mail.python.org/mailman/listinfo/python-list
