On Sunday 12 June 2005 07:33 am, Dan Sommers wrote: > > There is no case statement in Python. If you don't care about > > readability, one alternative is to use a dictionary: > > > case = {5: do_this, 6: do_that} > > case.get(x, do_something_else)() > > I find this very readable. YMMV.
Yeah, and I find this even more so: case = { 5: do_this, 6: do_that, } case.get(x, do_default)() Which is looking pretty close to a case statement, anyway. -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list