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:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410692

Hope that helps,

Hugo

铁石 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.
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to