Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created November 12, 2013 08:25
Show Gist options
  • Save chriszf/7427457 to your computer and use it in GitHub Desktop.
Save chriszf/7427457 to your computer and use it in GitHub Desktop.
I thought python could use some new syntax...
mac3:shenanigans czf$ cat 031_switchcase2.py
import lib.switchcase
def one():
print "One branch executed"
def two():
print "Two branch executed"
def three():
print "Three branch executed"
some_var = 2
switch(some_var, (one() for some_var in case(1)),
(two() for some_var in case(2)),
(three() for some_var in case(3)))
mac3:shenanigans czf$ python 031_switchcase2.py
Two branch executed
mac3:shenanigans czf$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment