Can global variable be passed into Python function?

Chris Angelico rosuav at
Fri Feb 28 15:37:33 CET 2014

On Sat, Mar 1, 2014 at 1:26 AM, Marko Rauhamaa <marko at> wrote:
> 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.
> Something like
>    switch self.state from Connection.State:
>        case CONNECTING or CONNECTED:
>            ...
>        case DISONNECTING:
>            ...
>        else:
>            ...
> 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
> Python.

Can you elaborate on this "nonliteral constants" point? How is it a
problem if DISCONNECTING isn't technically a constant? It follows the
Python convention of being in all upper-case, so the programmer
understands not to rebind it. Is the problem that someone might
(naively or maliciously) change the value of DISCONNECTING, or is the
problem that Python doesn't fundamentally know that it won't change?


More information about the Python-list mailing list