Re: [Tutor] switch-case in python

2006-02-28 Thread Ewald Ertl
Hi! Have a look to the Python-Cookbook at ActiveState. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410692 This is a recipe for simulating a switch. HTH Ewald 铁石 wrote: > I know this may seem to be stupid. > but as I found that there's no > switch-case control flow in python, > a

Re: [Tutor] switch-case in python

2006-02-28 Thread Hugo González Monteverde
Yep, it is an often mentioned thing. Using: --- if condition: action elif condition2: action2 else: defaultaction --- is pythonic. Also using a dictionary and indexing using the case is very fast and useful when there are many options. This approach is described here

Re: [Tutor] switch-case in python

2006-02-28 Thread Bob Gailer
铁石 wrote: > I know this may seem to be stupid. > but as I found that there's no > switch-case control flow in python, > an I just can't remember( or know) any > method to make such a control flow. > if cond1: stmts elif cond2: stmts ... else: stmts No need for break. > > > --