Can global variable be passed into Python function?
marko at pacujo.net
Fri Feb 28 15:26:23 CET 2014
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.
No need for the fallthrough (except that multiple cases should be
Labeled breaks wouldn't be needed because there are no fallthroughs.
> Would you still want to use it?
Guile (scheme) has:
(case (state self)
Python isn't "averse" to the switch statement because it would be not
that useful. Rather, the problem is that Python doesn't have nonliteral
constants (scheme has builtin symbols). It is difficult to come up with
truly Pythonic syntax for the switch statement.
switch self.state from Connection.State:
case CONNECTING or CONNECTED:
would be possible, but here, "Connection.State" is evaluated at compile
time. Don't know if there are any precedents to that kind of thing in
More information about the Python-list