Can global variable be passed into Python function?
roy at panix.com
Fri Feb 28 15:43:30 CET 2014
In article <87d2i7wbxs.fsf at elektro.pacujo.net>,
Marko Rauhamaa <marko at pacujo.net> wrote:
> Neil Cerutti <neilc at norwich.edu>:
> > 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
print "did case 1"
except (Case2, Case3):
print "did either case 2 or 3"
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
More information about the Python-list